[Resolved] Entry Meta Style

Home Forums Support [Resolved] Entry Meta Style

Home Forums Support Entry Meta Style

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1640167
    Vadik

    Hello
    Added code from Example 1 https://docs.generatepress.com/article/entry-meta-style/#example-1
    And this is what I did https://prnt.sc/xvw2b3
    I have a couple of questions

    Thanks

    Google translator

    #1640247
    Vadik

    For the first question, category inference found a solution in this post https://generatepress.com/forums/topic/i-want-to-move-the-category-display-above-the-title/#post-1014800
    screenshot
    I could not find an answer to other questions

    #1640713
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link me to your page in question?

    Please use the private info field.

    Thanks!

    #1640728
    Vadik
    #1640974
    Elvin
    Staff
    Customer Support

    As for removing the “Comment” and/or “Comments” string, you can use this PHP snippet:

    add_filter( 'gettext', function( $text ) {
        if ( '1 Comment' === $text ) {
            return '1';
        } if ( '% Comments' === $text ) {
            return '%';
        }
    
        return $text;
    } );

    As for showing the tags and categories on the archive and/or single pages, you should be able to do them through Appearance > Customize > Layout > Blog and click on “Single” tab and make sure “Display post tags” and “Display post categories” are checked as shown here: https://share.getcloudapp.com/rRukPOrY

    A wise man once said:
    "Have you cleared your cache?"

    #1641219
    Vadik

    Hello friends
    I am using Code Snippets plugin
    After connecting the code

    add_filter( 'gettext', function( $text ) {
        if ( '1 Comment' === $text ) {
            return '1';
        } if ( '% Comments' === $text ) {
            return '%';
        }
    
        return $text;
    } );

    There are no changes, comments are displayed in the same way as before the code was included Screenshot

    In the settings I have enabled to display tags on the post page Screenshot
    When I add the code from example 1
    My tags are disappearing Screenshot

    Thank you very much

    #1642177
    Elvin
    Staff
    Customer Support

    Ah right, I should’ve mentioned that it was just an example. My bad.

    You have to change the text string Comment and Comments within the PHP snippet’s line ( '1 Comment' === $text ) and ( '% Comments' === $text ) to the corresponding text/language that is displaying in your site.

    In the settings I have enabled to display tags on the post page Screenshot
    When I add the code from example 1
    My tags are disappearing Screenshot

    The PHP snippet provided on that example overrides the customizer settings. But you can add the tags manually if you must.

    Example:

    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array(
            'categories',
            'tags',
            'post-navigation',
        );
    } );

    A wise man once said:
    "Have you cleared your cache?"

    #1645113
    Vadik

    Hello friends
    sorry for the late reply
    I tried to find a solution myself, but I didn’t succeed

    Ah right, I should’ve mentioned that it was just an example. My bad.

    You have to change the text string Comment and Comments within the PHP snippet’s line ( ‘1 Comment’ === $text ) and ( ‘% Comments’ === $text ) to the corresponding text/language that is displaying in your site.

    I cannot figure out how to do this
    I only need to display the comment icon and the number.
    I do not need text leave a comment, comments, comment
    This is the code I added

    add_filter( 'generate_post_author_output', function() {
        return sprintf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
                esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date',		
            'comments-link',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array(
            'categories',
            'post-navigation',
        );
    } );
    // Open Post Image Wrap to contain image and category links
    add_action( 'generate_before_content','db_open_image_wrap',1);
    function db_open_image_wrap() {
    	if ( is_home() || is_archive() ) {
    	echo '<div class="post-image-wrap">';
    	}
    }
    
    // Remove categories from default position
    add_filter( 'generate_category_list_output','tu_remove_categories' );
    function tu_remove_categories( $categories ) {
    	if ( is_home() || is_archive() ) {
    		return '';
    	}
    	
    	return $categories;
    }
    
    // Add category link within Post Image Wrap
    add_action( 'generate_before_content','tu_cats_above_title', 15 );
    function tu_cats_above_title() {
    	if ( is_home() || is_archive() ) {
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $categories_list ) {
    			printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span></div>',
    				_x( 'Categories', 'Used before category names.', 'generatepress' ),
    				$categories_list
    			);
    		}
    	}
    }

    sorry for my English
    Thanks
    Google translator

    #1645171
    Elvin
    Staff
    Customer Support

    I only need to display the comment icon and the number.

    I thought you wanted to keep only the the icon and the number as mentioned here?
    https://generatepress.com/forums/topic/entry-meta-style-3/?action=bbp_favorite_add&object_id=1640167&_wpnonce=8a768b2fc6
    Return the comment icon and leave only the quantity https://prnt.sc/xvwgvc

    We need to remove the comment string using PHP snippets if you only want the icon and the number to display because the number of comment is coded along with the comment text.

    But you can just skip it if you changed your mind.

    As for showing the comment icon, you can add this CSS:

    .entry-header .gp-icon.icon-comments {
        display: inline-block;
    }

    A wise man once said:
    "Have you cleared your cache?"

    #1645188
    Vadik

    Thanks Elvin css code worked

    .entry-header .gp-icon.icon-comments {
        display: inline-block;
    }

    Screenshot
    Now how can I remove the text of comments and leave only the number
    Screenshot
    Thanks

    #1645239
    Elvin
    Staff
    Customer Support

    Now how can I remove the text of comments and leave only the number

    This is precisely what I was talking about on my previous replies. You really need to filter it out so the text string.T

    You can try this again but I’m not sure how it works as I’m not sure what’s the exact text string used in russian character translations.

    add_filter( 'gettext', function( $text ) {
        if ( '1 комментарий' === $text ) {
            return '1';
        } if ( '% комментариев' === $text ) {
            return '%';
        }
    
        return $text;
    } );

    A wise man once said:
    "Have you cleared your cache?"

    #1645290
    Vadik

    php code worked,
    but when there are no comments, the text “leave a comment” is displayed
    screenshot
    Can I fix this as well?
    thanks

    #1645302
    Elvin
    Staff
    Customer Support

    Can I fix this as well?

    Can you specify what you want to do with it? That’s the default behavior of WP’s comment link function.

    A wise man once said:
    "Have you cleared your cache?"

    #1645322
    Vadik

    When a post has no comments, then the text “Leave a comment” is displayed as in the screenshot
    I want to replace the text “Leave a comment” with the number 0 so that it looks like the screenshot
    Sorry I can’t explain well. I translate everything through google translator.

    #1645341
    Elvin
    Staff
    Customer Support

    Let’s modify the filter snippet into this.

    add_filter( 'gettext', function( $text ) {
        if ( '1 комментарий' === $text ) {
            return '1';
        } if ( '% комментариев' === $text ) {
            return '%';
        } if ( 'Оставьте комментарий' === $text ) {
            return '0';
        }
        return $text;
    } );

    If it doesn’t work, try modifying the text string Оставьте комментарий to the proper russian text.

    A wise man once said:
    "Have you cleared your cache?"

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.