Ready to get started?Download WordPress


Style menu item on specific category or post (12 posts)

  1. rechazame
    Posted 1 year ago #

    I have 10 posts which belong to category "Videos" and I have a page named "Videos" which list these posts using a plugin.

    When user clicks the "Videos" menu item, he reaches the "Videos" page and the menu item appears bold by default.

    I would like the "Videos" menu item also to be bold when the user enters one of the posts in the "Videos" category. What is the best way to do so?


    * Search results only led me to solutions on making menu items custom styled without any conditioning.

  2. what code is your theme using to generate the menu?
    what theme are you working with?

  3. rechazame
    Posted 1 year ago #

    I'm working with Twenty Twelve (child theme of it). The code is pretty much the default one... Haven't made any changes. Created a menu at the top of the website and that's it :)

  4. this article might be related (untested):
    - the section below this title 'Category highlighting for single posts'

  5. rechazame
    Posted 1 year ago #

    Yes, it is related. I read it and about 6 more like it (searched again with KW from the article you gave me).

    In all of them it seems that more experience and background are required so I need a bit more of a detailed guidance.

    They say to "custom class style" with the name ".current-menu-item". Do they mean creating a class in my theme style.css? And is ".current-menu-item" an arbitrary name or is it already a class which is used by the WP menu?

    Let me remind that I need a specific menu item highlighted whenever the visitor is in a post of category "videos".


  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Do they mean creating a class in my theme style.css?

    In your child theme's CSS, yes.

    And is ".current-menu-item" an arbitrary name or is it already a class which is used by the WP menu?

    It is generated by WordPress in the final page markup. Try using Firefox with the Firebug add-on for this kind of CSS troubleshooting. You'll find that it will cut the development time by half on this kind of work.

    Or use whatever developer tool is available in your web browser.

  7. rechazame
    Posted 1 year ago #

    Thanks, I use Firebug all the time but I lack some important observations regarding the way WP works and the process by which a page is being constructed.

    In my imagination, I expect some function to run whenever posts of category "videos" are being called. I assume it doesn't work exactly that way, so how do I do that? How do I condition a menu item to be highlighted on specific cat posts?

    Thanks guys..

  8. rechazame
    Posted 1 year ago #

    Update: After talking to someone I know, I have managed to define my goal a bit clearer.

    I want to create a condition similar to: if current post is of category "videos", then highlight menu item of label "Videos".

    Any ideas?

  9. try:

    .current-post-parent { font-weight: bold; }

    (should show bold on the category menu item where the post is in, not just 'video'; not tested if that also shows bold in other cases)

    don't forget to clear the browser cache after the change to the styles.

    if this is not it, it might help if you can post a link to your site so somebody can just use one of the browser inspection tools to check the available CSS classes to attempt the formatting.

  10. rechazame
    Posted 1 year ago #

    Yes please. Go to http://aye2.bachata.co.il/places/
    Log in back end using [login data moderated]
    enter one of the items in the portfolio
    notice that no menu item is being highlighted

    few details:

    items in page Places are posts of category Places
    menu item Places only links to page Places
    posts of category Places are listed in page Places using a plugin and thus have no logic connection to the page as far as WP concerns

    Thanks for pitching in :)

  11. access data moderated - please don't post access data in the forum.

    to get help with formatting here in the forum, the problem has to be visible in the public part of your site.

    for any support that involves logging in onto your site, please consider to post a job at http://jobs.wordpress.net/

  12. rechazame
    Posted 1 year ago #

    Sorry about that

Topic Closed

This topic has been closed to new replies.

About this Topic