WordPress.org

Ready to get started?Download WordPress

Forums

Adding posts to template (19 posts)

  1. Maracas1970
    Member
    Posted 2 years ago #

    Hi

    My site _ http://www.gotodesigns.co.uk/

    Having some issues trying to get the posts loop working, i have a static front page that has no loop on it, i only want my posts to appear on the blog page, i have put the loop on this page in the blog.php i created, but cant get the posts to show up. I have tried the changing front page to static and selecting the template page for my blog page in the settings reading section in admin panel, but each time i do that it just links to my homepage.

    I have created one post, i haven't created any categories so it goes in uncategorized. Is there some code i`m missing to pull posts into the page, or do i maybe need to create a template for my posts page?

    Ill do a paste of my current blog posts page markup to see if im missing the obvious, quite likely..

    http://pastebin.com/Kh26PbLe

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Your main posts page will use the index.php template file.

  3. Maracas1970
    Member
    Posted 2 years ago #

    So the loop needs to be there as opposed to the blog page itself?Sorry my head is going sideways with this, i`m on day three of trying to figure it out..
    And if it is the case, i dont want posts on my homepage, because as you`ll see it is a welcome/splash page with no content, if i do put the loop here wont it show up as a link to a non existent post on my frontpage?

    Thanks

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

  5. Maracas1970
    Member
    Posted 2 years ago #

    OK

    So i have got a post to show up and it takes me to a version of my homepage, with the banner etc, but i want it to not include that.I intend the blog page to be like the internal pages, without the large homepage banner.

    Also i added the <?php if (is_home()) { ?> <?php } ?>
    on the homepage to try and remove the traces of the loop, but it made the post disappear from the blogpage.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Stop messing with template files! Set up a static front page and a main posts page using the default page template first.

  7. Maracas1970
    Member
    Posted 2 years ago #

    I`ve done that though in the settings/reading section.

    I added two new pages one for blog one for home in admin/pages/add new. I called one home, and selected home from the drop down list.

    Then i selected the page for my posts to go on, which i entitled Articles (i selected my blog.php template on the drop down page attribute when creating this page). There is a copy of the loop on my template file for the blog.php and my index.php (homepage).

    Now artifacts from the loop are on my homepage and my blog posts appear on another version of my homepage..

  8. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    i selected my blog.php template on the drop down page attribute when creating this page

    Don't! It will not help in any way. As I said above, the main posts page uses the theme's index.php template file. Full stop. No exceptions.

    Your front page should now be using the default page template, yes?

  9. Maracas1970
    Member
    Posted 2 years ago #

    Yes it is, i changed back to default the blog page i created (articles) in the create new page, now all posts have dissapeared.

  10. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    The blog page will now be using the index.php template file, so it is this file that you need to investigate.

  11. Maracas1970
    Member
    Posted 2 years ago #

    OK thanks i appreciate the help really i do.

    Investigations are usually spurred along by clues, and as you no doubt are realizing i dont have one!

    As you can see by looking at the two pages, my homepage references "home" now and the blog page references "blog" The pages "loop" back on themselves..

    "I think" I need to change some parameter within the loop on the index.php for it to pull the posts to the blog page, just not sure which parameter.

    regards

    Maracas

  12. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    No - forget about blog.php. Delete it from the theme. You need to add a basic loop to index.php if it doesn't have one already.

  13. Maracas1970
    Member
    Posted 2 years ago #

    There is a loop on the index page, i can assure you of that.

    You see my homepage is different from my internal pages as it`s a template i coded myself, this may be where the misunderstanding is occurring. So if i delete the blog.php it will not be there in my navigation.

    So if i select the page after deleting blog.php will it still turn up in the nav, or will i have to change the link structure again to reflect the changes?

  14. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    So if i delete the blog.php it will not be there in my navigation.

    It shouldn't be there. A template file should never be referenced directly on the front end of a site. Perhaps you need to review Theme Development?

  15. Maracas1970
    Member
    Posted 2 years ago #

    The method i have used is purely to create each page in HTML/CSS. Then chop it up, and take out the header, footer content etc and turned them into individual php files along with a stylesheet and a resources folder. And that is basically my theme.

    I then created a page for each within WordPress and used the attributes section on each page to link up my navigation?

    This is totally wrong then?

    Regards

  16. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    This is totally wrong then?

    Yep. You need to create your pages within WordPress. And read up on how themes & their templates work.

  17. Maracas1970
    Member
    Posted 2 years ago #

    OK Thankyou.

    Should i just restart from the beginning then? Using one page i created as a blueprint for all pages? Or should i scrap the design (don't really want to do that) and do a new one and maybe reinstall wordpress?

  18. Maracas1970
    Member
    Posted 2 years ago #

    Sorry is the creating a page with css/html bit wrong or just the bit where i linked to them through the page attributes section. Some clarification would be immensely helpful at this stage, thank you.

  19. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Your whole approach is wrong. Please try reading http://codex.wordpress.org/Theme_Development

Topic Closed

This topic has been closed to new replies.

About this Topic