• Resolved samtemehr

    (@samtemehr)


    hi
    I want show 4 post from category and not show first post, please help.

    <ul>
    <?php $cat=16; ?>
    <?php query_posts("cat=$cat&showposts=4"); ?>
    <?php while (have_posts()) : the_post(); ?>        
                    <li>
                        <a href="<?php the_permalink() ?>" >
                        <?php the_title(); ?>
                        </a>
                    </li>
    <?php endwhile;?>
    <?php wp_reset_query(); ?>  
    </ul>
    • This topic was modified 6 years ago by samtemehr.
    • This topic was modified 6 years ago by samtemehr.
    • This topic was modified 6 years ago by samtemehr.
    • This topic was modified 6 years ago by samtemehr.
    • This topic was modified 6 years ago by samtemehr.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    get 5 posts, add a counter, skip the first.

    <ul>
    <?php 
      $cat=16;
      $i = 0;
      query_posts("cat=$cat&showposts=5"); 
      while (have_posts()) : the_post();  
       if ( $i++ > 0 ) { ?>       
                    <li>
                        <a href="<?php the_permalink() ?>" >
                        <?php the_title(); ?>
                        </a>
                    </li>
        <?php
        }
     endwhile;
     wp_reset_query(); ?>  
    </ul>

    more or less

    Thread Starter samtemehr

    (@samtemehr)

    @sterndata
    Thanks

    • This reply was modified 6 years ago by samtemehr.
    Thread Starter samtemehr

    (@samtemehr)

    exclude first post from tag?

    <?php $my_custom_query= new WP_Query(array( 'post_type' => 'post',
    		'post_status' => 'publish',
    		'tag'   =>   'test',
    		'order' => 'DESC',
    		'posts_per_page' =>'4',
    		
    		));
    		if($my_custom_query->have_posts()) : while($my_custom_query->have_posts()) : $my_custom_query->the_post(); ?> 
    		
    • This reply was modified 5 years, 10 months ago by samtemehr.
    • This reply was modified 5 years, 10 months ago by samtemehr.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘help:exclude first post from category’ is closed to new replies.