Display image every 5th post in visual composer 'Block 9'

Posted in: Newspaper
Post count: 1

Hi,

I’m trying to add an image every 5th post in a visual composer block (Block 9). Where is the loop that controls the posts that are displayed in that block?

I’m using the page-homepage-blank.php template, and the loop in that file doesn’t seem to be what i’m looking for.

I also tried td_module_8.php, but adding a counter in there didn’t seem to do the trick.

Is there somewhere else I shold be looking?

I’m not asking for you to do this for me, just point me in the right direction.

Thanks!

Post count: 6600

Hi,

Here is the function that handles each post from the block: http://screencast.com/t/hGf8Yjm3PTl you can try there.

Thanks

Post count: 64

Hi there,

the loop you’re looking for is in loop.php file:
\wp-content\themes\Newspaper\loop.php

But in loop.php, you can only control the loop and count how many posts the loop is rendering, you can’t control the rendering there. You can control the rendering in the file @Lucian mentioned.

So you have the loop in one file and the rendering in the other. You can make the loop tell the render that some post is the 5th it finds, but that means you’ll have to make the function pass on a new variable.

I believe there’s another easier way:
– create a copy of td_module_9 and call it td_module_10
– edit line 15 of the new td_module_10, replace this <?php echo $this->get_no_thumb_class();?> for this td_mod_no_thumb (this will make td_module_10 = td_module_9 but with no thumbs)
– add a counter to the loop.php
– add if-test to the loop.php, something like, if counter==is-multiple-of-5 and the block to render is td_module_9, then render td_module_10 instead

this should do the trick!
I hope this helps, cheers!

EDIT: oh, I noticed now you want “4-no-thumbs + 1-thumb” and what I wrote will get you “4-thumbs + 1-no-thumb”, just swap the steps I wrote and you’ll get 1 thumb every 5 posts.

  • This reply was modified 11 years by nf_prt.
  • This reply was modified 11 years by nf_prt.
Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.