• Good day!

    On a site I’m helping with they use some code to display the lastest 3 blog posts from a specific category.

    The code used can be found here: https://pastebin.com/xCzrqzj3

    The problem is that the post titles do not match the right posts. Everything is mashed up like this:

    The title from post A –– is listed above post B
    The title from post B –– is listed above post C
    Etc.

    I have already tried changing a few things, but i’m not a coding expert.

    It would be greatly appreciated if anyone could point out what’s going on!

    A sample of a live page can be found here: https://bit.ly/Ljujdi (Dutch)

    Thank you.

    Nick

Viewing 4 replies - 1 through 4 (of 4 total)
  • I believe you need to be running the_post(); just after line 17 in your pastebin code. Look at the main loop just above code that isn’t working. You are actually running the_post() too late for it do some of what it needs to do.

    Thread Starter nbijl

    (@nbijl)

    Thanks for your reply!

    Though I’m not quite sure if I totally get it. I tried to move the code up –– just like you said, I’m just not sure up til which line after the_post() should be moved up.

    I posted my complete page here: https://pastebin.com/bPhU1N0p

    If it’s not too much to ask, would you please link up a pastbin with the code you would have me use?

    Thanks again,
    Nick

    I’m just not sure up til which line after the_post() should be moved up.

    In your new file move it up to just after line 38. You will end up with this:

    <?php if (have_posts()) {
                           while (have_posts()) {
                               the_post();
                                    ?>
    Thread Starter nbijl

    (@nbijl)

    Bless you!

    That seemed to completely fix it ??

    Thanks a ton!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Wrong blog titles displaying on custom pages’ is closed to new replies.