WordPress current_page_item with post titles and changing colors

I will have 4 posts on my website, and the following loop will list them across all the pages of a website as a vertical menu (only post titles will be shown in this menu). After one of these will be clicked, it will load up the post as a new web page. What I’d like to have is for the current active post title (menu item) to be highlighted (just like with any regular website menu when you’re on a certain page). What can I add to the code below to make this happen? (I would then like to modify the colors etc. through CSS.)

Current code I have:

    <ul>
    <?php $posts = get_posts( "category_name=name_of_menu&numberposts=4&orderby=date&order=ASC" ); foreach($posts as $post) : ?>
    <li>
    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>
    </ul>

A few notes: I currently have this loop inside my single.php file, meanwhile the info outputs in to a Page. Basically it works like this: Page loads up, on the left are 4 post titles in a vertical menu (kind of like a sidebar). When you click on one, a new page loads which will contain that particular post’s content.

I am familiar with HTML and CSS, but not WordPress, so whatever I’ve tried doing with HTML hasn’t work for me thus far.

I tried editing current_page_item, but the thing is that I have a horizontal menu at the top of the website as well, so what happens is that neither of them display active/current color. The top horizontal menu is main menu, and the vertical (that I’m trying to get colors to work with) is vertical (left side of the page).

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories