Support » Theme: GeneratePress » Replace icons with text in post meta

  • Resolved kiparks

    (@kiparks)


    I’m editing my own child theme of GeneratePress and I would like to replace the icons (the folder and tags) that appear before the category and the tags for a post with a simple string of text.

    I’ve tried making my own function that emulates generate_entry_meta but I’m not sure what to edit within that function, or if that’s the correct step.

    Any help would be appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    First, add this CSS:

    .entry-meta *:before {
        display: none;
    }

    Then, you’ll want to overwrite the generate_entry_meta function with this: https://gist.github.com/generatepress/643fae12a42986754e0a

    Adding CSS: https://generatepress.com/knowledgebase/adding-css/
    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    Let me know if you need more info 🙂

    Thanks! The code worked, although I did adjust it slightly. (I put it below in case anyone else was interested)

    if ( ! function_exists( 'generatechild_entry_meta' ) ) :
    /**
     * Prints HTML with meta information for the categories, tags.
     *
     * @since 1.2.5
     */
    function generatechild_entry_meta()
    {
    	$categories = apply_filters( 'generate_show_categories', true );
    	$tags = apply_filters( 'generate_show_tags', true );
    	$comments = apply_filters( 'generate_show_comments', true );
    
    	if ( 'post' == get_post_type() ) {
    
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generate' ) );
    		if ( $categories_list && $categories ) {
    			printf( '<span class="cat-meta">Posted in: <span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span></span>',
    				_x( 'Categories', 'Used before category names.', 'generate' ),
    				$categories_list
    			);
    		}
    
    		$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generate' ) );
    		if ( $tags_list && $tags ) {
    			printf( '<span class="tags-meta">Tagged: <span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span></span>',
    				_x( 'Tags', 'Used before tag names.', 'generate' ),
    				$tags_list
    			);
    		}
    	}
    
    	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && $comments ) {
    		echo 'Comments: <span class="comments-link">';
    		comments_popup_link( __( 'Leave a comment', 'generate' ), __( '1 Comment', 'generate' ), __( '% Comments', 'generate' ) );
    		echo '</span>';
    	}
    }
    endif;

    And I set up the css to display it like so:

    .cat-meta,
    .tags-meta{
      display: block;
    }
    
    .cat-links,
    .tags-links{
      display: inline;
    }

    Thanks again!

    Theme Author Tom

    (@edge22)

    Awesome, thanks for posting your code! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Replace icons with text in post meta’ is closed to new replies.