[Support request] PHP for generating post term tags

Home Forums Support [Support request] PHP for generating post term tags

Home Forums Support PHP for generating post term tags

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1574318
    Antoinette

    Please can you give me the PHP snippet to generate a shortcode for generating post terms (tags and categories) to insert into templates using the Elements block?

    Thanks!

    #1574515
    David
    Staff
    Customer Support

    Hi there,

    you can do something like this:

    add_shortcode( 'display_terms', function() {
        ob_start();
        echo '<div class="entry-meta">';
         	generate_do_post_meta_item( 'categories' );
    	generate_do_post_meta_item( 'tags' );	
        echo '</div>';
        return ob_get_clean();
    } );

    This will create the [display_terms] shortcode

    #1574538
    Antoinette

    You wonderful person. That works like a dream, thank you.

    #1574554
    David
    Staff
    Customer Support

    You’re welcome – very happy to be of help – and really happy to see the use of the Block Element 🙂 In the future you will be able to do this without the need for shortcodes!

    #1574568
    Antoinette

    Amazing. It’s super useful and intuative, muuuuuuch easier than cowboying my way through the more complicated functions.

    #1575043
    David
    Staff
    Customer Support

    Totally true – and it will get better over time. Glad to hear your enjoying these features

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.