• Hello everybody!

    I’m building a website and I wanna show latest 5 posts of my blog in a section. I’m using this code:

    <?php require("blog/wp-blog-header.php"); query_posts('showposts=5'); ?>
    						<?php while (have_posts()) : the_post(); ?>
    							<ul class="list-unstyled">
    							<li><?php if ( '' != get_the_post_thumbnail() ) { ?>
    								<div class="post-link"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    								<?php the_post_thumbnail( array(80,80), array ("itemprop" => "image","class" => "img-responsive", "style"=> "float:left;margin:4px;") ); ?><?php the_title(); ?> <?php the_excerpt(); ?></a>
    								</div>
    								<?php }else{ ?>
    								<div class="post-link"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    								<?php echo '<i class="fa fa-file-o fa-4x" style="float:left;margin:4px;"></i> ';?><?php the_title(); ?> <?php the_excerpt(); ?></a>
    								</div>
    								<?php } ?>
    
    							</li>
    							</ul>
    						<?php endwhile;?>

    This code worked for me in local, but in my server shows only 3 posts, not five.

    Anybody could help me?
    Thanks in advance

Viewing 1 replies (of 1 total)
  • Thread Starter manuelfnavas

    (@manuelfnavas)

    For anybody lookin answers. Resolve it! I used this code:

    <?php require("blog/wp-blog-header.php"); $pc = new WP_Query('orderby=comment_count&posts_per_page=5')?>
    						<?php while ($pc->have_posts()) : $pc->the_post(); ?>
    							<ul class="list-unstyled">
    							<li><?php if ( '' != get_the_post_thumbnail() ) { ?>
    								<div class="post-link"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    								<?php the_post_thumbnail( array(80,80), array ("itemprop" => "image","class" => "img-responsive", "style"=> "float:left;margin:4px;") ); ?><?php the_title(); ?> <?php the_excerpt(); ?></a>
    								</div>
    								<?php }else{ ?>
    								<div class="post-link"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    								<?php echo '<i class="fa fa-file-o fa-4x" style="float:left;margin:4px;"></i> ';?><?php the_title(); ?> <?php the_excerpt(); ?></a>
    								</div>
    								<?php } ?>
    
    							</li>
    							</ul>
    						<?php endwhile;?>

    Be careful not refresh inmediatly… you have to wait

Viewing 1 replies (of 1 total)
  • The topic ‘Show worpdress posts in a web’ is closed to new replies.