[Support request] How to display only one tag instead of all ?

Home Forums Support [Support request] How to display only one tag instead of all ?

Home Forums Support How to display only one tag instead of all ?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1328545
    Francesco

    Hi, is there a way to have the script displays only the first tag and not the entire tags used in a post?

    thanks!

    #1328773
    David
    Staff
    Customer Support

    Hi there,

    try this PHP snippet:

    add_filter('term_links-post_tag', function($terms) {
        return array_slice($terms,0,1,true);
    } );
    #1328776
    Francesco

    Thanks, where should I add this ? function.php file ?

    #1328802
    David
    Staff
    Customer Support

    Yes, in your Child Theme functions.php or you can use the Code Snippets plugin

    https://docs.generatepress.com/article/adding-php/

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