简体   繁体   中英

Wordpress Select Navigation Menu Item

I am building a custom Wordpress plugin where I would like to highlight the item on the navigation menu corresponding to the plugin, either by the text in contains or the URL, whichever...

Is there a filter or action which I can hook into to select the appropriate menu item? My searching has been fruitless.

Thank you for your time.

I'm not sure how is our menu build it but,

You may try this snippet of code to do what you want.

<ul>
<li<?php 
                if (is_page('YourPlugin')) 
                { 
                echo " id=\"current\"";
                }?>>
                <a href="<?php bloginfo('url') ?>/YourPlugin">Plugin</a>
        </li>
</ul>

Now, you can change id=\\"current\\"" with any ID that have custom CSS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM