I'm using a customized php code for my wordpress loop. The code is designed the break the post up to be styled differently via html & css. The code is also designed so that I can add div blocks in between the post.

See the photo below for an example of the code's use.

Here is the code below that I am using.


My Problem is that the DIV that's suppose to come before the last 10 post is not showing up. I don't believe that it's an issue with my css file, but if you need those files too here they are.

Full Index.php file with HTML/PHP


Full CSS File


Here is a photo of what I am trying to accomplish.

enter image description here

The problem is that the DIV that has the Jeep AD is not being displayed. At all. Can anyone help me to find a solution as to why this is occurring.

1 Answer 1


You have this code:

elseif (17 < $count && $count <= 27 && $paged === 1) :
       if ($count === 10) echo 'DIV/CONTENT BEFORE THE NEXT 10 POST GOES HERE';

The first conditional fails when 10 === $count and so the second conditional can never succeed.

As your while loop executes (in a structure that WordPress calls The Loop, calling function the_post() to advance through the list of posts you are processing to generate this web page) $count is incremented as a way of keeping track of which post the code is working on.

When Bernie Sanders is being processed $count === 1, when we get to Drake's Album $count === 4 and so on until every post on the page has been rendered. The code doesn't have sections of posts with their own counts, there's just a count from the top, so your Jeep ad needs to be inserted when $count === 15 according to your picture. I'm not completely sure, as you have a block of 6 posts labelled as "next 9."

  • so how can i fix this problem @andy macaulay-brook Jul 22, 2016 at 11:11
  • That depends on what you intend those nested conditionals to do. Is $count just a count of how many posts you are up to in your loop? Jul 22, 2016 at 11:15
  • I think I may have a misunderstanding of the counts property. I thought that $count === was to equal to how many post to show. I hired a developer to develop this. I have some understanding if php coding but not this much. I'm trying to learn the best I can. Jul 22, 2016 at 11:18
  • I thought that 17 equaled the number of post already above, 27 represents 10 more post 17+10 = 27 and the $count === i was suppose to put 10. I would love some explaining on this. Jul 22, 2016 at 11:20
  • Thanks for clarifying the history and your position, it helps when framing responses. I've added to my answer. Jul 22, 2016 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.