Making a menu element bold when the page loads and bolding another menu element on click, here's what to do in WordPress
P粉547362845
2023-08-18 11:19:20
<p>I've searched for a long time but didn't find a good solution.
When I enter the site, I want the menu item DE to be bold, and if I click EN, I want DE to go back to thin, and EN to be bold. </p>
<p>The website is: https://kxplaw.live-website.com</p>
<p>Currently I successfully display elements with the current-menu-item class in bold, but this does not include the elements when I first open the page. </p>
<p>I've tried using JavaScript but I'm not quite sure how to make it work. </p>
Go to
Appearance -> Menu
and clickScreen Options
in the upper right corner. Then (if unchecked), check theCSS Classes
option and add a new field for each menu itemCSS Classes (optional)
andEN
andDE
add classmenu-language
.Only for
DE
Add classlang-DE
Only for
EN
Add classlang-EN
Now attached to click event
The selected language will now be bolded on every page.