• smoo

    (@smoo)


    Hi,
    is there a way to highlight the current post item in the navigation, in the same way it’s possible to highlight the current page?

    I am using mostly pages for my site, but have a ‘news’ section which is the blog, and am using get_archives() to list the posts even on single.php, but would like to show which post is the current one.

    I’ve found articles which show how to highlight the current archive, but not an actual post.

    It doesn’t seem such an odd requirement, but I can’t find anything anywhere, -am I asking in the wrong way?

    Thank you for any help
    -sam

Viewing 10 replies - 1 through 10 (of 10 total)
  • MichaelH

    (@michaelh)

    Thread Starter smoo

    (@smoo)

    Thank you for replying.

    However, I only need to highlight the current post, like current_page_item does for wp pages.
    Is there any other way of identifying the current post?
    -sam

    smoo – did you ever find an answer to this? I’m also wanting to achieve this without manually doing in my css code for each link

    Thread Starter smoo

    (@smoo)

    Hi bacollier,
    and no.. I didn’t ever find a solution.
    I imagine something could be done with the source code that says:
    “if this url is the same as the current page url,
    then
    apply x class to the anchor tag”

    but I’m not savvy enough to hack the php.
    I guess it would also interfere with future wordpress updates if you did, so probably not a good idea unless you know what you’re doing..

    How hard can it be tho?!
    -smoo

    Hi Guys,
    This is driving me nuts as well. Did anyone ever come up with a solution? I found this:

    https://www.kevinleary.net/highlight-current-wordpress-post-on-the-sidebar/

    Which seemed like a good solution but I couldn’t make it work. Is there nothing like current_POST_item?

    The site I am working on is visable here https://altuit.on-rev.com/cig-test/category/cignews/

    The way the blog part of the site works is visible on under the left 4 menu items. Each section is pulling from a post category with

    <?php query_posts(‘cat=1&showposts=3’); ?>

    I was able to use conditionals to build a dynamic sidebar and highlight the active page items and the archive pages when clicked. The client really wants to highlight the active blog post. Is there any way? Is anyone having any luck with the jQuery method on Kevin Leary’s site?

    Post are identified by a unique id. In your theme templates you can see the bit of code that outputs that:
    id="post-<?php the_ID(); ?>
    It shouldn’t be hard to append a specific class or change css on the fly using Javascript or PHP depending on id.

    Xamataca, Can you offer the php to do this? It seems like it would really help a few others in the same bind! The ideal solution for me would be something that uses query_posts so that we can limit the posts to one category.

    I’ve also been digging around for a solution to this problem. Found tons of tutorials on how to do this with a page menu you generate yourself, but nothing helpful for setting a class for current posts. Any help is appreciated.

    Thread Starter smoo

    (@smoo)

    Wow, thanks so much!
    Have just had to let it go with previous sites, but I’ll give that a go for the next one..

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘how to highlight current post?’ is closed to new replies.