Advertisement
salmancreation

How to Display full post or just excerpt using custom fields

Aug 5th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. Adding this snippet to the loop of your wordpress theme within single.php or index.php will let you use a custom field value to define if a post is displayed in full or just the excerpt.
  2.  
  3. <?php if (have_posts()) :
  4.     while (have_posts()) : the_post();
  5.          $customField = get_post_custom_values("full");
  6.          if (isset($customField[0])) {
  7.               the_title();
  8.               the_content();
  9.          } else {
  10.               the_title();
  11.               the_excerpt();
  12.     endwhile;
  13. endif;
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement