• Hello friends,
    i need to show in a custom page recent 5 posts.
    The code that i using is:

        <?php get_template_part( 'content', 'excerpt' ); ?>
    <?php wt_pagination(); ?>

    works 100% but shows only 1 post.
    How i can show 5 posts?

    Thanks for your support!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    the answer is probably in content-excerpt.php or in the PHP that’s calling that template part.

    Thread Starter Bluekid

    (@bluekid)

    thanks for reply Steve, can you explain me?
    in content-experpt.php i’ve this code:

    <?php?>
    <article <?php post_class(); ?> data-animation="fadeInLeft">
    	
    	<?php if ( has_post_thumbnail() ) {	?>
    		<div class="thumb excerpt-thumb overlay">
    			<a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'wt550_300' ); ?></a>			
    		</div>
    	<?php } ?>
    	
    	<div class="excerpt-wrap">
    	
    		<div class="entry-meta">
    			<?php wt_get_first_cat(); ?>
    				
    			<span class="author">
    				<?php _e('Author:', 'wellthemes'); ?>
    				<?php the_author_posts_link(); ?> 
    			</span>
    
    			<span class="sep">-</span>														
    			<span class="date"><?php echo get_the_date(); ?></span>	
    															
    			<?php				
    				$comment_count = get_comments_number($post->ID);
    				if ($comment_count > 0){ ?>	
    					<span class="comments">
    						<i class="fa fa-comment"></i>
    						<?php comments_popup_link( __('', 'wellthemes'), __( '1', 'wellthemes'), __('%', 'wellthemes')); ?>	
    					</span>					
    					<?php
    				}
    
    				if ( wt_get_option( 'wt_enable_rating' ) == 1 ){
    					ec_stars_rating_archive(); 
    				}
    			?>					
    		</div>	
    		
    		<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>		
    		<?php the_excerpt(); ?>
    		
    		<div class="excerpt-footer">
    			<div class="more-link">
    				<a href="<?php the_permalink() ?>"><?php _e('Read more', 'wellthemes'); ?></a>
    			</div>
    			<div class="share-links">
    				<span class="share"><?php _e('Share', 'wellthemes'); ?></span>
    				<span class="links">
    					<a class="twitter" href="https://twitter.com/home?status=<?php echo urlencode( get_the_title() ); ?>%20<?php echo urlencode( get_the_permalink() ); ?>" target="_blank"><i class="fa fa-twitter-square"></i><?php _e('Twitter', 'wellthemes'); ?></a>	
    					<a  class="fb" href="https://facebook.com/share.php?u=<?php echo urlencode( get_the_permalink() ); ?>&t=<?php echo urlencode( get_the_title() ); ?>" target="_blank"><i class="fa fa-facebook-square"></i><?php _e('Facebook', 'wellthemes'); ?></a>
    				</span>
    			</div>
    		</div>
    				
    	</div>
    	
    </article><!-- /post-<?php the_ID(); ?> -->
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    What theme are you using?

    Thread Starter Bluekid

    (@bluekid)

    what mean wordpresser. third class? can you help me?
    the theme is a wellthemes

    Thread Starter Bluekid

    (@bluekid)

    I think i solved… in the content-excerpt.php i add this code:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php static $count = 0;
    if ($count == "5") { break; }
    else { ?>
    
    ----------------HERE THE CODE OF CONTENT-EXCERPT.PHP----------------
    
    <?php $count++; } ?>
    <?php endwhile; ?>
    <?php endif; ?>

    it’s a good idea? what do you think?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    That should work!

    what mean wordpresser. third class?

    There’s a profile field for “additional title”. I was trying to make a joke.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘show recent 5 posts in a page using get_template_part’ is closed to new replies.