0

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.

https://gist.github.com/mihadaiko/dc314a845f807c16d19db8c842ed7a75

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

https://gist.github.com/mihadaiko/c4a9ef6f19c4b57cb239971d5e21d594

Full CSS File

https://gist.github.com/mihadaiko/4da7e1a4b8b9488a676ec175713a43f0

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.

0

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."

| improve this answer | |
  • so how can i fix this problem @andy macaulay-brook – Terrell Anderson Jul 22 '16 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? – Andy Macaulay-Brook Jul 22 '16 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. – Terrell Anderson Jul 22 '16 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. – Terrell Anderson Jul 22 '16 at 11:20
  • Thanks for clarifying the history and your position, it helps when framing responses. I've added to my answer. – Andy Macaulay-Brook Jul 22 '16 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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