• Hello,

    Recently i have started building my own site based on WordPress, i have never done this before so everything is new to me.

    Two things that are wrong with my theme i already know, the header </div> needs moving to header.php and the navigation </div> needs moving to navigation.php this isn’t my problem.

    If you look at my site i have a blog page https://oswestryweather.co.uk/blog/ i have attempted to get the loop to display all my posts here but for some reason it is not working.

    The code i am using is seen here https://pastebin.com/P07fusqy, what i think the problem is that this <?php while ( have_posts() ) : the_post(); ?> is in the wrong place however when i move it nothing happens and it makes an error.

    Any help would be extremely gratefully received

Viewing 15 replies - 1 through 15 (of 25 total)
  • All of your post/loop stuff needs to be between <?php while (have_posts()) : the_post(); ?> and <?php endwhile; ?>. That looks like most of lines 20 to 35.

    What is the error?

    Thread Starter thehowellsnest

    (@thehowellsnest)

    There is no error, no posts appear and i don’t know why.

    I have changed the code which you can see here https://pastebin.com/9xZ9QAm1 no difference.

    Take a look at the page i am trying to get it to work on, https://oswestryweather.co.uk/blog/ it just dosen’t show up.

    You said:

    …when i move it nothing happens and it makes an error.

    That wasn’t true?

    Insert this after line 20, and before line 21:

    <php var_dump($posts); ?>

    It will make a big mess. ??

    Thread Starter thehowellsnest

    (@thehowellsnest)

    Inserted it and still nothing;

    https://oswestryweather.co.uk/blog/

    What am i doing wrong?

    oops… typo 0_o

    <?php var_dump($posts); ?>

    I think you have messed up everything in the theme that your site cannot be validated. Please try validating here: https://validator.w3.org/

    Thread Starter thehowellsnest

    (@thehowellsnest)

    @krishna K – That is great and all but it dosen’t help me with this problem…i did say i was learning didn’t i? Did you ever learn anything and get it right FIRST time?

    @s_ha_dum – Okay now we have lost of things outputted https://oswestryweather.co.uk/blog/

    You want this page to be the blog index? The list of posts?

    What do you have set in wp-admin->Settings->Reading under “Front Page Displays”

    You can remove that var_dump, or comment it out for now.

    Also, the var_dump() may be the reason for the validation problem, but it might also indicate some other things. We’ll see.

    Thread Starter thehowellsnest

    (@thehowellsnest)

    What i have is a site which is running ontop of the wordpress CMS.

    the index.php doesn’t contain the post loop it is used some something else, i am trying to create a page template that i can use to create a page that will show ALL the posts that i have posted.

    Here are the settings from that page https://cl.ly/HGso

    Rich

    Ok. You do want this to be the index page.

    Go back to that Settings page and click the “A Static Page” box. Then select your “Blog” page from the menu next to “Posts Page”. You will probably have to select something for the “Front Page” as well. It can be squirrelly if you don’t.

    Thread Starter thehowellsnest

    (@thehowellsnest)

    No i don’t want this to be the index page, i want it to be a seperate page called blog?!

    Richard

    What content is this page supposed to display?

    Thread Starter thehowellsnest

    (@thehowellsnest)

    A list of posts, just like a normal blog…

    A list of posts, just like a normal blog…

    Ok. So you do want this to be a blog index, the blog list, not to be confused with index.php. Are you publishing all of your blog posts here, or just a subset of blog posts– maybe filtered by category or tag or something?

    Thread Starter thehowellsnest

    (@thehowellsnest)

    Hello,

    I ave uploaded the HTML code so that i can show you how i want the page to work you can see it here https://data.oswestryweather.co.uk/demo/blog.html yes i want this to be a blog INDEX not the INDEX.php.

    Hope this helps
    Rich

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Blog Post Loop’ is closed to new replies.