Loops - Showing Posts on Static Front Page (2 posts)

  1. neocharles
    Posted 3 years ago #

    Hopefully someone can help me out (completely over my head here).

    I have a page currently titled "General Information" which is set as the static front page. This page currently contains a few paragraphs of information that I would like to remain on the front page.

    I also have a "Blog Posts" page, which will contain all of the blog posts. The settings for these two have been set under Reading.

    My goal is to have a portion on "General Information" that displays some of the blog posts that have a specific category (ex: "Frontpage Posts") that will be 2-3 of the most recent posts in that category.

    How would I go about adding that, while maintaining the ability to add static content to that front page, and up to date posts from that category...


  2. Michael
    Part-Time Forum Moderator
    Posted 3 years ago #

    create a page template http://codex.wordpress.org/Pages#Page_Templates

    possibly using a copy of page.php as starting point;

    after the end of the existing loop ( http://codex.wordpress.org/The_Loop ) create a secondary loop with a custom query;


    <?php $frontpage_posts = new WP_Query( array( 'posts_per_page' => 3, 'category_name' => 'frontpage-posts' ) );
    if( $frontpage_posts->have_posts() ) :
    /*here possibly a FrontPage Posts title or so ? */
    while( $frontpage_posts->have_posts() ) :
    /*whatever you want to output - possibly copied from the loop of index.php*/
    else : echo 'no frontpage posts';
    endif; wp_reset_postdata();


Topic Closed

This topic has been closed to new replies.

About this Topic