- This topic has 16 replies, 3 voices, and was last updated 3 years, 1 month ago by Elvin.
-
AuthorPosts
-
January 31, 2021 at 1:12 am #1640167Vadik
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-
How can I transfer categories to the post thumbnail? https://prnt.sc/xvw8kr
Return the comment icon and leave only the quantity https://prnt.sc/xvwgvc
Return labels on the post page. Without php code connection https://prnt.sc/xvwp0i With php code included https://prnt.sc/xvwulwThanks
Google translator
January 31, 2021 at 3:30 am #1640247VadikFor 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 questionsJanuary 31, 2021 at 11:04 am #1640713LeoStaffCustomer SupportHi there,
Any chance you can link me to your page in question?
Please use the private info field.
Thanks!
January 31, 2021 at 11:14 am #1640728VadikTest site https://test.tesnoneo.tk/
January 31, 2021 at 5:00 pm #1640974ElvinStaffCustomer SupportAs 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
February 1, 2021 at 1:13 am #1641219VadikHello friends
I am using Code Snippets plugin
After connecting the codeadd_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 ScreenshotThank you very much
February 1, 2021 at 3:17 pm #1642177ElvinStaffCustomer SupportAh right, I should’ve mentioned that it was just an example. My bad.
You have to change the text string
Comment
andComments
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 ScreenshotThe 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', ); } );
February 4, 2021 at 12:17 am #1645113VadikHello friends
sorry for the late reply
I tried to find a solution myself, but I didn’t succeedAh 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 addedadd_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 translatorFebruary 4, 2021 at 1:13 am #1645171ElvinStaffCustomer SupportI 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; }
February 4, 2021 at 1:40 am #1645188VadikThanks 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
ThanksFebruary 4, 2021 at 2:13 am #1645239ElvinStaffCustomer SupportNow 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; } );
February 4, 2021 at 3:01 am #1645290Vadikphp code worked,
but when there are no comments, the text “leave a comment” is displayed
screenshot
Can I fix this as well?
thanksFebruary 4, 2021 at 3:12 am #1645302ElvinStaffCustomer SupportCan 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.
February 4, 2021 at 3:33 am #1645322VadikWhen 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.February 4, 2021 at 4:00 am #1645341ElvinStaffCustomer SupportLet’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. -
AuthorPosts
- You must be logged in to reply to this topic.