[Resolved] See the tags and categories on post

Home Forums Support See the tags and categories on post

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #934177
    Iñaki Mansilla

    HI,
    I see this solution in order to show the tags and categories below the title of the post.
    On wich file I have to add it? and how not be affected by the next updates?
    Thank you,

    add_action( 'generate_after_entry_title', 'tu_add_meta_below_title' );
    function tu_add_meta_below_title() {
        $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        $categories_list = sprintf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
            _x( 'Categories', 'Used before category names.', 'generatepress' ),
            $categories_list
        );
    
        $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
        $tags_list = sprintf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    		esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
    			$tags_list
    	);
    
    	?>
    	<div class="entry-meta">
    		<?php echo $categories_list; ?>
    		<?php echo $tags_list; ?>
    	</div>
    	<?php
    #934465
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    If you’re using GP 2.3, you can now do this:

    add_filter( 'generate_header_entry_meta_items', function( $items ) {
        $items[] = 'categories';
        $items[] = 'tags';
    
        return $items;
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        unset( $items['categories'] );
        unset( $items['tags'] );
    
        return $items;
    } );

    This code can be added using one of these methods: https://docs.generatepress.com/article/adding-php/

    Then you can add this CSS:

    .entry-header .cat-links, 
    .entry-header .tags-links {
        display: block;
    }

    Let me know 🙂

    #935537
    Iñaki Mansilla

    ok thanks Tom!!.

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