WordPress.org

Ready to get started?Download WordPress

Forums

cbnet Different Posts Per Page
Am I dense? (3 posts)

  1. caitc
    Member
    Posted 1 year ago #

    So I'm new to coding, so please bear with me for no doubt asking a really dumb question. So I see where the options are under Dashboard - Settings-Reading, but I'm not sure then how to direct my posts to the different pages.
    Here is my site: http://sealink.org/

    right now I just want that one, first post to be on home page, and start directing future posts to other pages. I made a test post, put 'blog' as the category, then made a 'Blog Page' on my website. But I can't figure out how to make the post, categorized as blog' to actually go to the page. Where do I go to do this?

    Thanks so much for this plug-in, I really want it to work...I just need to get over my own idiocy, so please help!

    http://wordpress.org/extend/plugins/cbnet-different-posts-per-page/

  2. Chip Bennett
    Theme Review Admin
    Plugin Author

    Posted 1 year ago #

    Hi caitic,

    First: no question is a dumb question. We all ultimately started at the same place. :)

    This Plugin isn't really designed to do what you're trying to accomplish. It sounds like you want your site front page to display the latest blog post, and then have all other posts appear on a different page?

    If so, you really want to look at using a static page as your site front page. Reference the Codex here:
    http://codex.wordpress.org/Creating_a_Static_Front_Page

    Follow those instructions, and you'll have a static page as your front page, and your blog posts index on a separate page. At that point, you'll be half-way to where you need to be.

    The next thing you'll need to do is create a special, custom page template, named front-page.php, to display your custom content. In your case, your custom content will be a loop with the single, most-recent blog post.

    Without knowing what Theme you use, I can't provide specifics, but assuming your page.php template looks something like this:

    <?php get_header(); ?>
    
    <div id="content">
    
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
             <?php // Loop markup here ?>
    
        <?php endwhile; endif; ?>
    
    <?php get_sidebar(); ?>
    
    </div>
    
    <?php get_footer(); ?.

    You'll need to make a change to this part:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
         <?php // Loop markup here ?>
    
    <?php endwhile; endif; ?>

    Replace that with this:

    <?php
    $latest_post_query_args = array(
        'posts_per_page' => 1
    );
    $latest_post = new  WP_Query( $latest_post_query_args );
    ?>
    
    <?php if ( $latest_post->have_posts() ) : while ( $latest_post->have_posts() ) : $latest_post->the_post(); ?>
    
         <?php // Loop markup here ?>
    
    <?php endwhile; endif; ?>
    <?php wp_reset_postdata(); ?>

    Now, WordPress will use your front-page.php template to render the static front page, and the front page will display the latest blog post.

  3. caitc
    Member
    Posted 1 year ago #

    Thanks Chip! For your answer of course but for being so patient with me as I learn.

    I had thought of doing the static page, but the person I'm doing the website for is thinking down the road they would like to be able to split posts up and direct them to different pages. So eventually I'd need to learn how to do that.

    But am I still confused on what this plug in is for and trying to use it wrong?

    Thank you SO much for taking the time to give me that coding for the front-page.php template. Should I still implement that? Can you give me some guidance on then how I'd split the posts up between different pages?
    Sorry for all my questions!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic