WordPress.org

Forums

Limit number of displayed posts only in Homepage (2 posts)

  1. joia
    Member
    Posted 1 year ago #

    Hi and thanks for the help in advance...
    Im trying to set to 3, the number of displayed posts (Only) in homepage, while keeping 10 or more displayed posts in any of the other category pages, but I can not figure out how to do it.

    This is the code in my index.php
    Hel me please...

    <?php global $theme; get_header(); ?>
    
        <div id="main-main">
    
            <?php $theme->hook('main_before'); ?>
    
            <div id="content-index">
    
                <?php $theme->hook('content_before'); ?>
    
                <?php
                    $is_post_wrap = 0;
                        if (have_posts()) : while (have_posts()) : the_post();
    
                        /**
                         * The default post formatting from the post.php template file will be used.
                         * If you want to customize the post formatting for your homepage:
                         *
                         *   - Create a new file: post-homepage.php
                         *   - Copy/Paste the content of post.php to post-homepage.php
                         *   - Edit and customize the post-homepage.php file for your needs.
                         *
                         * Learn more about the get_template_part() function: http://codex.wordpress.org/Function_Reference/get_template_part
                         */
    
                        $is_post_wrap++;
                            if($is_post_wrap == '1') {
                                ?><?php
                            }
                            get_template_part('post', 'homepage');
    
                            if($is_post_wrap == '2') {
                                $is_post_wrap = 0;
                                ?><?php
                            }
    
    						if($is_post_wrap == '3') {
                                $is_post_wrap = 0;
                                ?><div class="post-wrap clearfix"><?php
                            }
    
                    endwhile;
    
                    else :
                        get_template_part('post', 'noresults');
                    endif; 
    
                        if($is_post_wrap == '1') {
                            ?><?php
                        } 
    
                    get_template_part('navigation');
                ?>
    
                <?php $theme->hook('content_after'); ?>
    
            </div><!-- #content -->
                        <!--
                         * Aqui deve colocarse o sidebar.
                         * Verificar index-original.php
                         -->
     <div class="entry clearfix">  </div>
        </div><!-- #main -->
    
    <?php get_footer(); ?>
  2. vtxyzzy
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic