• Hi

    My site _ https://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..

    https://pastebin.com/Kh26PbLe

Viewing 15 replies - 1 through 15 (of 18 total)
  • Your main posts page will use the index.php template file.

    Thread Starter Maracas1970

    (@maracas1970)

    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

    Thread Starter Maracas1970

    (@maracas1970)

    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.

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

    Thread Starter Maracas1970

    (@maracas1970)

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

    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?

    Thread Starter Maracas1970

    (@maracas1970)

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

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

    Thread Starter Maracas1970

    (@maracas1970)

    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

    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.

    Thread Starter Maracas1970

    (@maracas1970)

    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?

    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?

    Thread Starter Maracas1970

    (@maracas1970)

    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

    This is totally wrong then?

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

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Adding posts to template’ is closed to new replies.