Need Help: Full Post Content for Sticky Post, Excerpt for Rest

  • Anonymous

    #962

    Hey All-

    This is my first build with the Graphene theme, and it’s wonderful! Amazing work. I am looking to create a sticky post that displays in full, with all the other posts below it showing only excerpts. I found a post where Syahir addressed this by saying:

    “The posts on front page are showing excerpts by default. If you want the sticky post to show the full content, you’d have to use the graphene_before_post_content and graphene_after_post_content action hooks. This is actually not that difficult to achieve is you know your way around PHP.”

    How would I go about doing this? I’m comfortable editing the .php files and what not, just need to be pointed in the correct direction.

    Thanks again, and great work!

    Admin

    Syahir Hakim

    #14095

    Try adding this into your child theme’s functions.php file:

    function graphene_full_sticky(){
    if (is_sticky()) {
    $content = get_the_content();
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    return $content;
    }
    return get_the_excerpt();
    }
    add_filter('the_excerpt', 'graphene_full_sticky');

    And of course, set the posts to display as excerpts on the front page in the theme’s options page.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.