Advertisement
ridgey28

WP Custom Field Teaser, Image and Summary

Nov 16th, 2015
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. <?php
  2. $args = array( 'numberposts' => 6, 'order' =>'DESC', 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
  3. //'order' above can be changed to 'ASC'
  4.  
  5.  
  6. $postslist = get_posts( $args );
  7.  
  8. foreach ($postslist as $post) : setup_postdata($post); ?>
  9. <div class="events">
  10.  
  11. <!------------------------Teaser---------------------------------------->
  12.    
  13. <!--You can display your own teaser using custom fields (in the blog post editor), providing that each post has the same custom field name (in this case teaser)  -->
  14. <?php echo get_post_meta($post->ID, 'teaser', true);?>
  15.    
  16.    
  17. <!-------------------------Content--------------------------------------->    
  18.  
  19. <!-- The content displays all the content in the blog post including any html and images.
  20. If you wish to display a snippet use <?php the_excerpt();?>, this removes all images and HTML
  21. You can also use the quick tag <!--more--><!-- in your blog posts to provide a cut off point
  22. and still use the_content();?>-->
  23. <?php the_content();?>
  24.  
  25. <!--------------------------Images---------------------------------------->    
  26. <!-- the post thumbnail can be used to fetch a feature image, which can be set in post editor
  27. (bottom right) can be useful if you use excerpt above -->
  28. <!--<?php the_post_thumbnail();?>-->
  29.  
  30. <!-- If you want more control over the size of the feature image change the_post_thumbnail() to: -->
  31. <!--<?php echo get_the_post_thumbnail($post->ID, 'full'); ?>-->
  32.  
  33. <!-- The above will display the full size of the image. You can change this for medium or large too or
  34. specify a custom size below-->
  35.  
  36. <!--<?php echo get_the_post_thumbnail($post->ID, array(100,100), 'thumbnail');?>-->
  37.  
  38.  
  39.  
  40. </div>
  41. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement