• I’m not that familiar with php so this is doing my head in. What I’ve done so far is set up Advanced Custom Fields to enter a post summary/metadata which is then posted in a blockquote at the top of each post.
    I’ve managed to use this data to create an excerpt in the manual excerpt field consisting of:

    Rating:  [field rating]<br>
    Keywords:  [field keywords]<br>
    Summary:  [field summary]<br>
    Words:  [wpwordcount]<br>
    Estimated Reading Time: [rt_reading_time postfix="minutes" postfix_singular="minute"]

    This works exactly as I want, but I’m hoping to avoid putting this on every “category – story” page manually. Can someone please help me with adding this to all pages of a particular category (or tag or some sort of manual override to allow for the odd exception)?

    I’d really appreciate any advice. Thanks.

Viewing 1 replies (of 1 total)
  • First of all. WordPress by default does not support the categories on the “pages” post type. So, i think you mean posts.

    It depends a lot on what possibilities your current theme offers to hook content in a specific location of your website posts.

    
    function ar_add_new_content( $content ) {
        global $post;
        $post_cat = get_the_category( $post->ID );
        if ( $post_cat[0]->name === 'Markup' ) {
            $extra = '<p>Summary: [summary]</p>';
            return $extra .= $content;
        }
        return $content;
    }
    add_action( 'the_content', 'ar_add_new_content' );

    For example, this code will check your current post category, and if the name is Story, then, it will show all the content you put inside $extra variable.

    Let me know if this is what you are looking for.

    • This reply was modified 6 years, 9 months ago by Anass Rahou.
Viewing 1 replies (of 1 total)
  • The topic ‘Create a standard excerpt for posts using shortcodes’ is closed to new replies.