Support » Themes and Templates » Reducing number of posts shown on Front page of WP-creativix

  • Hi there, I’m trying to reduce the number of posts that are showing up on my front page in the latest-posts list to 4. Any more that this and it throws everything out Can’t seem to find where to change it. Can someone please help?
    Thanks

Viewing 1 replies (of 1 total)
  • You have to dive in to some code here.

    1. Create a WordPress child theme to contain you changes so you can update the parent theme. Read more about child themes:
    http://codex.wordpress.org/Child_Themes
    http://wpthemetutorial.com/2012/04/26/adding-a-sidebar-to-twentyeleven-with-a-child-theme/

    2. Copy index.php in to the child theme.

    3. Pasted the code below over the existing loop code.

    <h2>Latest Articles</h2>
                    <h3>Latest Articles from the Blog</h3>
                    <ul class="latest-posts">
                            <?php
    
                              // defining the arguements for the custom loop
                              $latestPosts = new WP_Query( array(
                                'posts_per_page'            => 10, // neg 1 means all posts
                                'orderby'                   => 'date',
                                'order'                     => 'DESC',
                              )); // end query
    
                            while ($latestPosts->have_posts()) : $latestPosts->the_post();
    
                            ?>
    
    				<li id="latest-post-<?php the_ID();?>"><a href="<?php the_permalink();?>" title="<?php the_title();?>"><?php the_title();?></a><span class="date">Published <?php the_time(get_option('date_format')); ?> at <?php the_time(get_option('time_format'));?></span></li>
    
                            <?php endwhile;?>
    
                            <?php wp_reset_query(); ?>
                    </ul>

    You can then change the posts_per_page value to whatever you’d like. That will change the number of posts in the latest posts area of the site.

Viewing 1 replies (of 1 total)
  • The topic ‘Reducing number of posts shown on Front page of WP-creativix’ is closed to new replies.