- This topic has 42 replies, 5 voices, and was last updated 5 years, 3 months ago by
Tom.
-
AuthorPosts
-
December 10, 2020 at 2:27 am #1574044
Sourabh
for more information, you can also refer snap –
https://www.dropbox.com/s/g4ssatjc8ofcksf/read%20mins%20time%20snap.png?dl=0
Also, let me know what is that “float” above reading time mins ??
December 10, 2020 at 11:07 am #1574739Tom
Lead DeveloperLead DeveloperCan you try this code, instead?: https://generatepress.com/forums/topic/how-can-additional-content-be-included-in-each-grid-post-on-the-home-page/#post-1241829
December 10, 2020 at 11:17 am #1574751Sourabh
No, It seems worse, refer below –
https://www.dropbox.com/s/wsp4pf4jeuo6668/read%20mins%20css%202nd.png?dl=0
Regds:
December 10, 2020 at 11:20 am #1574756Tom
Lead DeveloperLead DeveloperHere’s the complete code:
function tu_estimated_reading_time() { $post = get_post(); $content = $post->post_content; $wpm = 300; // How many words per minute. $clean_content = strip_shortcodes( $content ); $clean_content = strip_tags( $clean_content ); $word_count = str_word_count( $clean_content ); $time = ceil( $word_count / $wpm ); if ($time == 1) { return $time . ' minute'; } else { return $time . ' minutes'; } } add_filter( 'generate_post_author_output', function( $output ) { $output .= '<div class="read-time">Reading time: ' . tu_estimated_reading_time() . '</div>'; return $output; } );December 10, 2020 at 11:32 am #1574768Sourabh
Hi Tom,
It seems working, Looking like below –
https://www.dropbox.com/s/ufwvmpbiu5gcvb6/Meta%20Reading%20%20time.png?dl=0
can you help me to set it in a format in a row –
Like
Author By: | Date | Comments | Reading Time etc…
(Good if also getting one line up and one line down, it’s like two lines box), give a CSS for arranging this.
December 10, 2020 at 7:58 pm #1575231Tom
Lead DeveloperLead DeveloperGive this a shot:
.read-time { display: inline-block; border-left: 1px solid #ddd; padding-left: 5px; margin-left: 3px; }December 11, 2020 at 1:39 am #1575546Sourabh
Hi Thanks Tom,
Above CSS worked only for reading time (As all in a row now), thanks for that, But I requested CSS for the entire Meta Like below format-
Author By: | Date | Comments | Reading Time | …
(Good if also getting one line up and one line down, it’s like two lines box), give a CSS for arranging this.
Help if you can please.
December 11, 2020 at 10:55 am #1576524Tom
Lead DeveloperLead DeveloperThere seems to be an error on your website when trying to view a single post at the moment.
You can see how to re-order/add to your post meta items here: https://docs.generatepress.com/article/generate_header_entry_meta_items/
December 12, 2020 at 7:04 am #1577480Sourabh
Yes Tom,
My site is broken again, It’s happening because of the child theme, Don’t know whats wrong, (I have raised a separate ticket for my child theme concern), Please review that, so that i will restore it again from backup…
however a meta is a concern, I have already read this article it’s about metadata, however, I requested custom CSS for the entire Meta display in the below format-
Author By: | Date | Comments | Reading Time | …
(Good if also getting one line up and one line down, it’s like two lines box), give a CSS for arranging this.
https://www.dropbox.com/s/rc7251uh61goazx/Meta%20below%20title.png?dl=0
December 12, 2020 at 11:33 am #1577762Tom
Lead DeveloperLead DeveloperLet’s figure out the error first, then we can re-open this one and provide some CSS.
December 12, 2020 at 11:42 am #1577778Sourabh
Yes I like your decision..
December 18, 2020 at 7:26 am #1586047Sourabh
HI Tom,
the issue has been resolved so Let’s finish this topic and give me CSS for the below –
Author By: | Date | Comments | Reading Time | …
(Good if also getting one line up and one line down, it’s like two lines box), give a CSS for arranging this.
December 18, 2020 at 1:05 pm #1586449Tom
Lead DeveloperLead DeveloperWe’ll need to change it up to rearrange where the reading time goes. This is the updated code:
function tu_estimated_reading_time() { $post = get_post(); $content = $post->post_content; $wpm = 300; // How many words per minute. $clean_content = strip_shortcodes( $content ); $clean_content = strip_tags( $clean_content ); $word_count = str_word_count( $clean_content ); $time = ceil( $word_count / $wpm ); if ($time == 1) { return $time . ' minute'; } else { return $time . ' minutes'; } } add_action( 'generate_post_meta_items', function( $item ) { if ( 'reading-time' === $item ) { echo '<span class="reading-time">Reading time: ' . tu_estimated_reading_time() . '</span>'; } } ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'comments-link', 'reading-time', ); } ); add_action( 'wp', function() { if ( is_single() ) { add_filter( 'generate_show_comments', '__return_true' ); } } );More info on this method here: https://docs.generatepress.com/article/generate_header_entry_meta_items/
As for the lines, try this:
.entry-header .entry-meta { border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 5px 0; margin-top: 10px; }December 19, 2020 at 1:38 am #1586757Sourabh
Nah, Something went wrong seems –
Tom, Reading time + Comments section is not visible now, they vanished post updating the code, should i jump to the previous one ??
I think I have a few codes which Leo has given to me previously as below –
add_action( ‘wp’, function() {
if ( is_single() ) {
add_filter( ‘generate_show_comments’, ‘__return_true’ );
}
} );add_filter( ‘generate_header_entry_meta_items’, function() {
return array(
‘categories’,
‘date’,
‘author’,
);
} );However, when I delete these codes from the child theme then to it’s looking like this (Refer private section),
Guide me on what to do now from here ..
December 19, 2020 at 12:46 pm #1587444Tom
Lead DeveloperLead DeveloperI’ve adjusted the functions here: https://generatepress.com/forums/topic/post-visit-counter-and-mins-read-time/page/2/#post-1586449
Make sure those are the only post meta related functions you have active on your site – backup and then remove the others.
-
AuthorPosts
- You must be logged in to reply to this topic.