WordPress.org

Ready to get started?Download WordPress

Forums

Adding a blog to my static front page (6 posts)

  1. hpwg
    Member
    Posted 1 year ago #

    I've read a lot (a lot) of posts/instructions on this, but am yet to find an answer. That works on my site, or works in the home page template .php

    I've got a static home page with a slider image at the top. Underneath this, I would like my blog feed. As it would appear on the blog page (with thumbnails, read-more, description etc..) with the 6 latest posts from posts and a custom named posts.

    I've read a lot about the get posts command. But it doesn't treat it or appear as it does if my static page was set to the "latest posts" or "blog".


    I've made a crude mockup so you can see what I mean.

    Any help on this would be appreciated. Thank you.

  2. cdukes
    Member
    Posted 1 year ago #

    get_posts will grab the posts you ask for from the DB. To display them, you have to use a loop to designate what content you want with which HTML tags around it.

    Depending on your theme's configuration, you may be able to copy the loop from your blog template with little modification. Otherwise, you'll have to write a custom one and translate the CSS to work. Take a look at WP_Query for an example of how to start.

  3. hpwg
    Member
    Posted 1 year ago #

    Thanks Cooper - the best way seems to be copying the loop from my blog template. That way I can have my widgets down the side too.

    Where would I find the code for this blog template to copy?

    I've spent the last week customising this theme (bought online) and never come across it.

    Thank you.

  4. cdukes
    Member
    Posted 1 year ago #

    Depends on how your theme is setup. Work through the http://codex.wordpress.org/Template_Hierarchy

    I find the best way is to open a template in FTP, delete everything inside of it, and reload the blog page. If the page isn't blank, it wasn't that file. (N.B. make sure you have a backup and can undo the delete.)

  5. hpwg
    Member
    Posted 1 year ago #

    Thanks Cooper - I ended up adding my slider to the top of the blog post. Works perfectly.

    As a side note, the blog pulls the latest 5 "posts" which is great. But I have a custom "recipe" type which isn't a post or a page. Would you know how I'd go about getting them included on my latest blog feed?

    Thank you.

  6. hpwg
    Member
    Posted 1 year ago #

    Thanks Cooper - I'll add a new post for this.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.