Advertisement
ridgey28

Custom Display WP blog posts on non-wp page

Aug 27th, 2013
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. $args = array( 'numberposts' => 6, 'order' =>'DESC', 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
  2. //'order' above can be changed to 'ASC'
  3.  
  4. Further improvement
  5. //wrapped the_title (below) in H3 tags
  6.  
  7. $postslist = get_posts( $args );
  8.  
  9. foreach ($postslist as $post) : setup_postdata($post); ?>
  10. <div class="events">
  11.     <!-- The date will only be displayed once for posts posted on the same day use
  12.              <?php echo get_the_date(); ?> to display on each post-->
  13.              <div class="date"><?php the_date(); ?></div>
  14.  
  15.     <!--The title just displays the post title and not permalink -->
  16.              <h3><?php the_title(); ?></h3>
  17.                            
  18.         <!-- The content displays all the content in the blog post including any html and images.
  19.          If you wish to display a snippet use <?php the_excerpt();?>, this removes all images and HTML
  20.              You can also use the quick tag <!--more--><!-- in your blog posts to provide a cut off point
  21.              and still use the_content();?>-->
  22.          <?php the_content();?>
  23.                            
  24.     <!-- the post thumbnail can be used to fetch a feature image, which can be set in post editor
  25.             (bottom right) can be useful if you use excerpt above -->                          
  26.             <?php the_post_thumbnail();?>
  27.  
  28.     <!-- If you want more control over the size of the feature image change the_post_thumbnail() to: -->
  29.          <?php echo get_the_post_thumbnail($post->ID, 'full'); ?>
  30.  
  31.     <!-- The above will display the full size of the image. You can change this for medium or large too or
  32.      specify a custom size below-->
  33.  
  34.     <?php echo get_the_post_thumbnail($post->ID, array(100,100), 'thumbnail');?>
  35.  
  36.     <!--Also make sure your theme supports thumbnails, add the following (if not already there) to
  37.      functions.php-->
  38.     <?php add_theme_support( 'post-thumbnails' );?>
  39. </div>
  40. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement