Site logo

Archived topic

Remove entry_meta on Category Excerpt

3 replies · Started by John on March 7, 2017

Viewing posts 1–4 of 4

Hi Tom,

I am using a child them and I have my posts to set to display excerpts on the category page. I am running into a problem on the category page where beneath the excerpt it is displaying all of my entry meta info (tags & category). On the posts, I want this information to display.

I have this code already in my functions.php file. However, if I change it from "true" to "false" it works, but then I lose the information on my posts.

Is there a way to have it set for true on posts and false on category page?

if ( ! function_exists( 'generate_entry_meta' ) ) :
/**
 * Prints HTML with meta information for the categories, tags.
 *
 * @since 1.2.5
 */

function generate_entry_meta() 
{
	$categories = apply_filters( 'generate_show_categories', true );
	$tags = apply_filters( 'generate_show_tags', true );
        $tagf = apply_filters( 'generate_show_tags', false );
	$comments = apply_filters( 'generate_show_comments', false );

	
	$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
	if ( $categories_list && $categories ) {
		printf( '<h3>Other Jobs Completed in %2$s</h3>',
			_x( 'Locations', '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' ) );
        if ( $tags_list && $tags ) {
		printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
			_x( 'Services', 'Used before tag names.', 'generatepress' ),
			$tags_list
		);
        }

	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && $comments ) {
		echo '<span class="comments-link">';
		comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
		echo '</span>';
	}
       
}
endif;

The filters make it pretty easy to adjust using a function.

For example:

add_filter( 'generate_show_categories','tu_alter_category_meta' );
function tu_alter_category_meta( $meta ) {
    // Remove on categories
    if ( is_category() ) {
        return false;
    }

    // Otherwise, show the meta
    return $meta;
}

You would do this for each filter.

Also, the upcoming version of GP filters the actual outputs of each meta item, so you wouldn't have to overwrite the entire function anymore. I'll revisit this post with an updated solution for you once the update is out.

I'll also sending out betas right now if you'd like to give it a try :)

Thanks Tom. Worked like a charm for both tags and category excerpts!

I use GP & GP Prem as my primary theme for all sites (I have a lot). I'd be happy to try the beta.

This archived topic is closed to new replies.