[Support request] How to show tags?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support How to show tags?

Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1772
    Jeroen
    Participant

    Hi there, starting to learn WPSP. Is there a way to show the tags of a post below each entry in a list?
    I saw the option Include terms. This will show the category of a post at the bottom of each entry. I looked for a similar option like Include tags.
    JW

    #1778
    Tom
    Keymaster

    Currently it can only display the terms based on the taxonomy selected.

    I can see the usefulness in being to display terms taxonomy terms though (categories, tags etc..).

    I just opened it as an issue to fix: https://github.com/tomusborne/wp-show-posts/issues/8

    #1786
    Jeroen
    Participant

    Thanks. Would be great to have it.

    #3450
    Denise
    Participant

    Hello WPSP Friends,

    This thread was opened several months ago. It’s now January 2018. Is there any update on when we might have the ability to show post tags in the meta data, next to the date and category?
    This is an essential requirement for my site and I’d really like to use WP Show Posts Pro, since I’m also using GeneratePress pro.
    If not, can you suggest a work-around? Perhaps a hook or filter that I can put in the functions.php?

    Many thanks,
    Denise

    #3467
    Denise
    Participant

    Hi Tom,

    I was able to get the tags to display in the meta data area of WP Show Posts after the title by using the code pasted below.
    This is the format: date | category | tag1, tag2, tag3
    The date format I’m using is short month and year. (Jan 2018)
    This puts pipe separators between each item. And the separator for multiple tags is a comma.

    add_action( 'after_setup_theme','tu_move_post_meta' );
    function tu_move_post_meta() {
        remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
        add_action( 'wpsp_after_title','wpsp_add_custom_meta' );
    }
    function wpsp_add_custom_meta() {
        $cat_title = single_cat_title("",false);
        $year  = get_the_time('Y'); 
        $month = get_the_time('m'); 
        $date = '<a href="https://www.mydatapal.com/' . $year .'/'. $month . '/">' . get_the_time('M Y') . '</a>';
        $cats = get_the_category_list( ', ');
        $tags = get_the_tag_list(' | ',', ');
        echo '<div class="mdp-meta">' . $date . ' | ' . $cats . $tags . '</div>' ;
    }

    Not sure if that’s the most elegant solution, but it worked =)
    Thanks again for the awesome support and plugin!
    ~ Denise

    #3468
    Tom
    Keymaster

    Looks great!

    Instead of the $date format you have set up, you may be able to do this:

    add_action( 'after_setup_theme','tu_move_post_meta' );
    function tu_move_post_meta() {
        remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
        add_action( 'wpsp_after_title','wpsp_add_custom_meta' );
    }
    function wpsp_add_custom_meta() {
        $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    
        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
        }
    
        $time_string = sprintf( $time_string,
            esc_attr( get_the_date( 'c' ) ),
            esc_html( get_the_date() ),
            esc_attr( get_the_modified_date( 'c' ) ),
            esc_html( get_the_modified_date() )
        );
    
        $date = '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>';
    
        $cats = get_the_category_list( ', ');
        $tags = get_the_tag_list(' | ',', ');
        echo '<div class="mdp-meta">' . $date . ' | ' . $cats . $tags . '</div>' ;
    }
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.