WordPress.org

Ready to get started?Download WordPress

Forums

Blog Post Loop (26 posts)

  1. thehowellsnest
    Member
    Posted 2 years ago #

    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 http://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 http://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

  2. s_ha_dum
    Member
    Posted 2 years ago #

    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?

  3. thehowellsnest
    Member
    Posted 2 years ago #

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

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

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

  4. s_ha_dum
    Member
    Posted 2 years ago #

    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. :)

  5. thehowellsnest
    Member
    Posted 2 years ago #

    Inserted it and still nothing;

    http://oswestryweather.co.uk/blog/

    What am i doing wrong?

  6. s_ha_dum
    Member
    Posted 2 years ago #

    oops... typo 0_o

    <?php var_dump($posts); ?>

  7. Krishna K
    Member
    Posted 2 years ago #

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

  8. thehowellsnest
    Member
    Posted 2 years ago #

    @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 http://oswestryweather.co.uk/blog/

  9. s_ha_dum
    Member
    Posted 2 years ago #

    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.

  10. thehowellsnest
    Member
    Posted 2 years ago #

    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 http://cl.ly/HGso

    Rich

  11. s_ha_dum
    Member
    Posted 2 years ago #

    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.

  12. thehowellsnest
    Member
    Posted 2 years ago #

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

    Richard

  13. s_ha_dum
    Member
    Posted 2 years ago #

    What content is this page supposed to display?

  14. thehowellsnest
    Member
    Posted 2 years ago #

    A list of posts, just like a normal blog...

  15. s_ha_dum
    Member
    Posted 2 years ago #

    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?

  16. thehowellsnest
    Member
    Posted 2 years ago #

    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 http://data.oswestryweather.co.uk/demo/blog.html yes i want this to be a blog INDEX not the INDEX.php.

    Hope this helps
    Rich

  17. s_ha_dum
    Member
    Posted 2 years ago #

    So you need to assign that page as the "Posts Page" as I instructed several comments ago. That is step #1.

  18. thehowellsnest
    Member
    Posted 2 years ago #

    I have changed the settings like you said - http://cl.ly/HFs7

    Now when i try and load any page it re-directs me to the homepage.

    I am not doing something right...

  19. s_ha_dum
    Member
    Posted 2 years ago #

    I am not doing something right...

    Yes, probably, and it is hard to debug without direct access. Be patient.

    You will need to select something for the "Front Page". That is the catch. I don't like that it works that way but I have never been able to get reliable behavior otherwise.

  20. thehowellsnest
    Member
    Posted 2 years ago #

    It still dosen't work i have selected something for the home page and it still dosen't work.

    The BLOG page loads the homepage - this is very confusing especially when i am trying my best to learn..

  21. s_ha_dum
    Member
    Posted 2 years ago #

    Did you set the front page to something that uses a different page template?

    Is there any way you can get this online? It is getting hard to guess at things without being able to look at them.

  22. thehowellsnest
    Member
    Posted 2 years ago #

    Yep i set the home page to a separate page and the blog page to the blog page.

    What do you want me to show you?

    Richard

  23. s_ha_dum
    Member
    Posted 2 years ago #

    I'd really like to see the site. I am missing something and I don't know what.

  24. thehowellsnest
    Member
    Posted 2 years ago #

    Do you have some form of offline chat?

  25. thehowellsnest
    Member
    Posted 2 years ago #

    Can anyone help me with this?

  26. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    possibly re-read
    http://codex.wordpress.org/Template_Hierarchy
    http://codex.wordpress.org/Theme_Development

    what is the code of index.php in your theme?

    what is the file name of the pastebin code?
    from the code in the pastebin, this looks like a page template;
    in which case, to get it to show all posts, you need to add a query before the loop, i.e. before this line: <?php while ( have_posts() ) : the_post(); ?>

    example:
    <?php query_posts('posts_per_page=-1&post_type=post'); ?>

    btw: what about the page 'The Blog':
    http://oswestryweather.co.uk/the-blog/
    this at least shows a single post; do you have any more than this post?

Topic Closed

This topic has been closed to new replies.

About this Topic