More
    Home Design / Dev Manually Define to Show Full Post or Excerpt on Your WordPress Homepage

    Manually Define to Show Full Post or Excerpt on Your WordPress Homepage

    Are you using excerpts or full posts on your blog posts homepage? By default, there is no way to use both excerpts and full posts on your blog homepage at the same time. However there is a hack that can enable that. This way you can show full post and excerpts at the same homepage. Here’s a hack to do it.

     

    On your index.php file, replace your current loop by this one:

    while (have_posts()) : the_post();
    $customField = get_post_custom_values("full");
    if (isset($customField[0])) {
    //Custom field is set, display a full post
    the_title();
    the_content();
    } else {
    // No custom field set, let's display an excerpt
    the_title();
    the_excerpt();
    endwhile;
    endif;
    

    The code above, default is displaying excerpts. If you want to show a full post on your blog homepage, simply edit the post and create a custom field named full and give it any value.

    Avatar
    WPTidBitshttps://wptidbits.com/
    Owner of WPTidBits. Totally in love with WordPress!

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    110FansLike
    761FollowersFollow

    You May Also Like