Title: Do not understand this code
Last modified: August 21, 2016

---

# Do not understand this code

 *  [joia](https://wordpress.org/support/users/joia/)
 * (@joia)
 * [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/)
 * Please, 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 with this code… Can you help?
 *     ```
       <?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(); ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Mark Ratledge](https://wordpress.org/support/users/songdogtech/)
 * (@songdogtech)
 * [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/#post-3763066)
 * It’s easiest to use [WordPress › Custom Post Limits « WordPress Plugins](http://wordpress.org/extend/plugins/custom-post-limits/)
 *  Thread Starter [joia](https://wordpress.org/support/users/joia/)
 * (@joia)
 * [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/#post-3763069)
 * Thank you for the opinion, but I dont want to use more plugins.
    Im sure the 
   solution is simple… I just want to give the instruction for displaying only 3
   posts on homepage, while I can control the number of posts on the category pages
   to 10, by goind to settings > reading.
 * I understand the code using query…but I dont know what to do with this code.
   
   Please help
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/#post-3763121)
 * You will be more satisfied with the level of support of [http://jobs.wordpress.net](http://jobs.wordpress.net),
   post a listing there.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/#post-3763122)
 * > but I dont want to use more plugins.
   >  Im sure the solution is simple…
 * you can for instance look through the code of that suggested plugin to see if
   you can find how they have coded it, for that simple solution.
 * _[please condtinue with your original topic – [http://wordpress.org/support/topic/limit-number-of-displayed-posts-only-in-homepage?replies=1](http://wordpress.org/support/topic/limit-number-of-displayed-posts-only-in-homepage?replies=1)]_

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Do not understand this code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/do-not-understand-this-code/#post-3763122)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
