Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You’re going to need to use something like https://codex.www.ads-software.com/Function_Reference/get_post_type_object to access the description parameter, to the best of my knowledge.

    Say you have a post type of “my-type”.

    $mytype = get_post_type_object( 'my-type' );
    if ( ! empty( $mytype ) ) {
        echo $mytype->description;
    }
    Thread Starter preston41

    (@preston41)

    Hi Michael,
    So should I place this in my child themes functions.php?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The snippet above, as is, would be used wherever you need to echo the description. It’s not typed up to be a standalone function that you put in a functions.php file.

    I’m not aware of any WordPress core function built to display the descriptions, so you’d need to create your own.

    function preston_display_post_type_description( $post_type_slug = '' ) {
        $mytype = get_post_type_object( $post_type_slug );
        if ( ! empty( $mytype ) ) {
            echo $the_post_type->description;
        }
    }
    <p><?php preston_display_post_type_description( 'my-type' ); ?></p>
    Thread Starter preston41

    (@preston41)

    I created a test child theme
    copied over index.php and headline.php

    added this to headline.php

    <?php echo term_description( $term_id, $taxonomy ) ?>
    <?php $description = term_description(); ?>

    It has given me the description but not the pictures or social media links

    Before I saw your code

    Thread Starter preston41

    (@preston41)

    Thank you, Michael

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Note that your provided snippet from 2 replies above is for terms, not post types. Different things here.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display custom post type description’ is closed to new replies.