Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Resolved] How do I only have post titles appear in categories

Home Forums Support [Resolved] How do I only have post titles appear in categories

Home Forums Support How do I only have post titles appear in categories

  • This topic has 3 replies, 2 voices, and was last updated 3 years ago by Leo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #555964
    Robin

    Is there a way to only show the post titles in a category. Like this.

    I want the image and excerpt removed.

    Thanks in advance…

    GeneratePress 2.0.2
    GP Premium 1.6.2
    #556128
    Leo
    Staff
    Customer Support

    Hi there,

    This snippet should remove featured image on category pages:

    add_filter( 'option_generate_blog_settings', 'lh_remove_category_featured_image' );
    function lh_remove_category_featured_image( $options ) {
        if ( is_category() ) {
            $options['post_image'] = false;
        }
        return $options;
    }

    This should remove the excerpt on category pages:

    add_filter( 'excerpt_length','lh_custom_excerpt_length', 1000 );
    function lh_custom_excerpt_length( $length ) 
    {
        if ( is_category() ) {
            return 0;
        } else {
            return $length;
        }
    }

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

    #556223
    Robin

    Thanks Leo. Much appreciated.

    #556570
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.