WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. rechazame
    Member
    Posted 2 months 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?

    Thanks,
    Rechazame

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

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

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

  3. rechazame
    Member
    Posted 2 months 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. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

    this article might be related (untested):
    http://www.mor10.com/highlight-current-page-or-category/
    - the section below this title 'Category highlighting for single posts'

  5. rechazame
    Member
    Posted 2 months 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".

    Thanks..

  6. esmi
    Theme Diva & Forum Moderator
    Posted 2 months 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
    Member
    Posted 2 months 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
    Member
    Posted 2 months 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. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

    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
    Member
    Posted 2 months 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. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

    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
    Member
    Posted 2 months ago #

    Sorry about that

Reply

You must log in to post.

About this Topic