• Resolved cpkid2

    (@cpkid2)


    I have a page set up that queries 6 posts. In the case there are only five posts and I want to show a dummy image for the last post, is there a way to do that?

    Something like: If post doesn’t exist, then show dummy.gif.

    Code here: https://pastebin.com/pUeSg8Xz

    I’m focused on lines 13-17.

Viewing 6 replies - 1 through 6 (of 6 total)
  • https://pastebin.com/KQ3SxuEc

    Warning: Untested

    Thread Starter cpkid2

    (@cpkid2)

    Thank you for your time, esmi. However, for some reason only one post + one dummy image post is showing.

    Here is my full code: https://pastebin.com/5kVU6GMC (I changed it to query 4 posts instead of the original 6)

    In the output, only one post and one dummy post shows instead of having one post and three dummy posts showing.

    Any ideas?

    I can see why. You need another looping structure to pick up where the primary Loop stopped. Try https://pastebin.com/Gu6Mie6A

    Thread Starter cpkid2

    (@cpkid2)

    I get an unexpected semicolon on line 32.

    Parse error: syntax error, unexpected ';', expecting ')' in blog.php on line 32

    Thread Starter cpkid2

    (@cpkid2)

    I changed line 32 from:

    <?php if( $c < 4 ) : for ($dummy= $c; $dummy < 5; $dummy++;) : ?>

    to:

    <?php if( $c < 4 ) : for ($dummy= $c; $dummy < 4; $dummy++) : ?>

    I removed the last semicolon and it seems to be working now. Also, I’m wondering why there was a ‘5’ in the original line instead of ‘4’? Is that necessary for the code to work or was it a mistake? It outputted 5 boxes so I changed it to 4 and it’s working now.

    It was all very much off the top if my head. If 4 works, go for it. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘!have_posts, show temporary dummy image’ is closed to new replies.