Skip to main content

Forums

This topic contains 10 replies, has 0 voices, and was last updated by  chrisburton 8 years, 8 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #30492

    chrisburton
    Participant

    I have a WordPress Homepage and a Blog Page. Somehow I would like to have the latest/most recent blog post to be on the homepage. I tried googling and inserting a few php codes but none seemed to work.

    Anyone know of a quick tutorial or solution to this?

    #67811

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    I’m assuming I could use this php code and reference that… if it’s the homepage, display recent post.




    ...get recent post

    whatever, i can’t code php, but you get my point.

    #67813

    Johnnyb
    Member

    You could just use query_posts within that if statement at the start of your loop, or you could use a custom loop for index.php and use it in there:

    < ? php query_posts('posts_per_page=1'); ?>
    
    
    #67814

    Johnnyb
    Member

    By the way I really recommend chris’s book diggin into wordpress, it explains this in there. The PDF copy is only $27 and well worth it if you’re considering using wordpress on a regular basis.

    #67820

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    Here’s my problem though, my index.php is for domain.com/blog and not domain.com. So if I change anything to the index.php file, it changes the blog page. Would I have to create a seperate php file for my home page or?

    I have these pages made on wordpress

    -Home (My “front page”)
    -Blog (Where My Blog Posts are set at on my settings)
    -Services (Services Page)
    -Portfolio (Portfolio Page)
    -Contact (Contact Page)

    #67824

    Johnnyb
    Member

    I always prefer the second option, someone else might be able to advise you better on a way to achieve it using the first way though. One option could be to pull the latest post using RSS, although there may be a better way.

    #67825

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    Thanks. Basically I want exactly how @chriscoyier has his set up on his personal website’s homepage and blog.

    He has his latest post on the homepage AND a blog page for multiple posts.

    I should mention I put my wordpress files in a folder called “wordpress” so I had to copy the index.php file (below) to my root directory.



    <?php
    /**
    * Front to the WordPress application. This file doesn't do anything, but loads
    * wp-blog-header.php which does and tells WordPress to load the theme.
    *
    * @package WordPress
    */

    /**
    * Tells WordPress to load the WordPress theme and output it.
    *
    * @var bool
    */
    define('WP_USE_THEMES', true);

    /** Loads the WordPress Environment and Template */
    require('./wordpress/wp-blog-header.php');
    ?>
    #67833

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    Here is a visual.

    #67835

    Jerm993
    Member

    ahh, what you need to do is the query posts as Johnny suggested and create a separate page for your homepage and your blog, page-slug.php, slug being the title of the page, created in wp admin, then have your index be a basic loop, with links to header and footers as index.php is mainly a fallback if there isn’t any other pages for them to use, so if there isn’t a single.php, or a page.php, they fall back to index.php. check out template hierarchy here:
    http://codex.wordpress.org/Template_Hierarchy

    #67844

    chrisburton
    Participant

    This reply has been reported for inappropriate content.

    I found an alternate way to do this without creating custom pages.

    I installed “inline posts” plugin for wordpress.

    This way I just enter “post ID” in my home page and it pops up. The only downside is I will have to do this for every post I create. The upside is, it only takes 30 seconds.

    But if someone wants to make the process more clearly for others, it is much appreciated!

    #67855

    Jerm993
    Member

    that works also^^

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star