About Sridhar Katakam
I am an independent WordPress web consultant with 10 years of experience in WordPress theme installation, customization, administration, maintenance, support, documentation, troubleshooting and PSD/design to WP.
Genesis and WordPress Tutorials
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
can you explain what this part is doing and why you chose to use current_post?
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
Thanks.
“current_post” is the index (which starts with 0) of the current post.
For the latest post, the value of $wp_query->current_post is 0. For the latest post and every third post we want the “first” class to be assigned to the .entry.
That’s done using the if conditional:
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
Latest post (let’s say, n) : 0 (this should get the ‘first’ class)
n-1: 1
n-2: 2
n-3: 3 (this should get the ‘first’ class)
n-4: 4
n-5: 5
n-6: 6 (this should get the ‘first’ class)
…
…
…
“%” is the modulo operator. It gives the reminder of a division.
ah, ok. that makes sense. Thanks for breaking it down further.
This would be interesting to use to break down categories into columns too.
Maybe a loop running through post categories to be featured, showing the latest post of each category in 3 columns.Like the bottom part of NYtimes.com website.
just thinking through it…I’d need a loop to run through each category, then list the first post and its meta.
Would it be best to include the post class in that loop or add it after like you have here.
Maybe I’ll give it a go and see if I can’t figure it out.
Thanks again.
Craig
does this work for other genesis child themes?
Yes.
Depending on the child theme that is active, you may have to add a few further add/remove actions to get your desired output.
Hi Sridhar,
Welcome back online 🙂 This seems trivial but I have tried to add an add image code in my functions:
add_image_size( ‘blog-featured-image’, 300, 300, TRUE );
and regenerated thumbnails
but the featured images are not changing sizes. Do you have any ideas what I might be able to do? Thank you!
Have you un-commented lines 36 to 40 and commented line 41 in the code added in functions.php?
That was it!! Thanks a million!
One other question… how can I make it so that this does not apply to category or archive pages?
Thank you so much Sridhar. I am gonna give it a try.
i would love to have the 3 columns for my website in Metro pro. Can you advice what to change in the code?
Warm regards, Marjolein
Thanks for sharing
Hi Sridhar, I tried this, but it doesn’t seem to change anything. This is my website: https://www.pilatesglossy.com. What did I do wrong?
Regards, Marjolein