Did you ever wanted to distinguish your newest post in front of the other posts in the list ? This snippet will allow you to make your latest post look different (in any category) and to dinstinct itself from the rest.
Where to copy/paste this code? The best way to customize a theme in WordPress is to create a child theme. Everything you need to know about child theme creation in Customizr here
1. Filtering
First we need to add additional css classes for our latest post. We can do this by adding this short function in the function.php file of the child theme:
add_filter( 'post_class', 'latest_post_class' ); function latest_post_class( $classes ) { global $wp_query; if( 0 == $wp_query->current_post ) $classes[] = 'latest'; return $classes; }
We now have new .latest class that we can use to style our latest post.
2. Styling
The following code should be copied into the custom css section or in style.css of your child theme. For this example, we will make our latest post to distinguish itself with few elements in crimson color:
.latest h2.entry-title.format-icon { color: crimson; } .latest h2.entry-title a { color: crimson; text-shadow: -1px -1px white, 1px 1px #333; } .latest .entry-summary { background-color: #FCE8EC; }
Of course, all custom css styling can be applied, for all entry elements, like entry-title, entry-summary and entry-meta, e.g. tag and category links.
14 thoughts on “Emphasize latest post on the list”
Thank you very much for this. It is what I’m looking for. I only have one question. Is there a way to make this post full width and above the sidebar? I’m thinking along the lines of below the header. maybe using something like __after_header, but I’m new at this, and don’t really know php that well. Any pointers? Thanks -Austin
Hi Austin,
We are about to add a feature to Customizr allowing you to do this from the theme customizer (appearance > customize).
Stay tuned!
Awesome! We can not wait. Thank you very much for this fantastic and easy to use theme.
Hi Nicolas,
thanks for your awesome theme! I would like to know if this feature (last one post in full width and for example the 3 next post in small width) is available. I couldn’t find it in the customization options.
Thanks, Manuel
Hi Manuel,
This feature exists when you choose the grid mode, see it in live demo here : http://demo.presscustomizr.com
Cheers 🙂
Hi,
thanks for reply. I saw your demo and is exactly what i need, but i can’t make it works. I enabled the option “Expand the last sticky post (for home and blog page only)” but not working.
the post need to have specific category or something else I’m missing?
The configuration is:
customize -> content home,post,.. -> post list :
Maximum number of posts per page: 4
Select the length of posts in lists (home, search, archives, …): excerpt
Excerpt lenght: 50
Grid layout
Number of column: 3
Expand the last sticky post (for home and blog page only): YES
apply the grid layout to home : YES
Thankyou very much.
Hey, sorry!!! I understood the problem! the post have to be “STICKY” in publish option! ooops! thanks again!!! cheers 🙂
Hi Tomaja,
I’ve applied your snippet above as it works exactly as expected on my postings page ( http://www.commercialrc.ie/news/ ).
But….
I’ve got a static home page (see ‘News’ widget at commercialrc.ie) and I’d like the colour to change there too. I had expected the snippet would change the colour in both places.
Any ideas?
Many thanks (btw I’m an amateur wordpress user and I think Customizr is fantastic).
Lee
Hi Tomaja,
I have a question related to this topic – I see that this code will let you change the background color of the latest post, my question is how can I change the background of a specific post. For example if I want to create a post and make it sticky, do you know how I would be able to change the background color of that post? I’m hoping the code would be similar. Would appreciate any help. Thanks!
I found the answer to my own question. Here is the code to change background color of a post item on your blog page
Thanks for sharing Brian!
hi,
how can i only display ‘featured posts’ on the start page?
how can i define a post as ‘featured’?
thx
Hi Samuel,as far as I know Customizr theme uses default WordPress […] for end of excerpts, not “See more” or “Read more” links. Anyway. when I need something like “Read more” link I usually use this function in functions.php file (always use child theme functions.php):
Now you have new .read-more class, so you can easily use css to remove it from display, like:
If you can share link to your site, it could be much easier. There are few other options to remove it too. For that you can check Codex page
Hi Tomaja! Nice to be writing to you man!
I really need your help !
Let me explain my little problem to you!
All my posts are showing one message like this at the bottom of them “See more”, in all of posts we can see that.
My question and request is:
How can I move it away from there because I just don`t want it there and just don´t need it there as well?
Is it possible?
How to do that please? teach me please!
Thanks in advance,
Samuel Carlos