-
AuthorPosts
-
June 7, 2024 at 9:23 pm #1448636
Hi,
is there a way to place this shortcode on my blog-entries: [rt_reading_time label=”Lesedauer:” postfix=”Minuten” postfix_singular=”minute”] ? I would like to display the reading time when an article is hovered. It should be on the bottom right corner.Best regards
June 9, 2024 at 4:50 pm #1448719Hey northorie,
Thank you for the link to your site, it looks like you are using the masonry element and I believe that your shortcode is for the Reading Time WP plugin. I tested this on my demo site and found that adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function add_reading_time_to_masonry_entry($content, $entry, $config) { $reading_time_html = "<div class='reading-time'>" . do_shortcode('[rt_reading_time post_id="' . $entry['ID'] . '" label="Reading Time:" postfix="minutes" postfix_singular="minute"]') . "</div>"; $content .= $reading_time_html; return $content; } add_filter('avf_masonry_entry_content', 'add_reading_time_to_masonry_entry', 10, 3);
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
and adding this CSS in your Enfold Theme Options ▸ General Styling ▸ Quick CSS field:.av-inner-masonry .reading-time { opacity: 0; bottom: 0; position: absolute; right: 0; } .av-inner-masonry:hover .reading-time { opacity: 1; }
will add the reading time at the bottom right corner on hover only, like this:
Best regards,
MikeJune 10, 2024 at 4:24 pm #1448787Hi,
thank you!
It’s not working for me. What did I do wrong?Can I have it also without hovering. It want to see, what looks better :)
June 10, 2024 at 9:08 pm #1448812Hi,
Did you copy the code from the forum and not an email notification so the symbols were not converted?
Please include an admin login in the Private Content area so we can check.Best regards,
MikeJune 12, 2024 at 2:25 pm #1449057Hi, yes I did.
Admin-Login on Private content.Best regards
June 12, 2024 at 4:10 pm #1449078Hi,
Thank you for the link to your site, but the login is not admin so I can not see any of the theme settings or the custom code that you added, please check.Best regards,
MikeJune 13, 2024 at 1:47 pm #1449418Oh sorry, changed it to admin.
best regards!
June 14, 2024 at 2:44 am #1450040Hi,
Thank you for the update.
The excerpt is currently disabled, but it needs to be enabled for the above modification to work. We adjusted the filter so that the reading time appears after the title instead of after the content. Please check it again. The reading time should display on hover.
Best regards,
IsmaelJune 16, 2024 at 1:34 pm #1451375Hi Ismael,
thank you. Reading time is displayed but doesn’t look good, because the font is way too big. Can the font only for reading time in the headline be decreased?Best regards!
June 16, 2024 at 2:28 pm #1451379Hi,
Try this CSS in your Enfold Theme Options ▸ General Styling ▸ Quick CSS field:#top #wrap_all .all_colors h3 .span-reading-time { font-size: 12px; }
and adjust the font size to suit.
After applying the css, please clear your browser cache and check.Best regards,
MikeJune 16, 2024 at 3:58 pm #1451384Way better :) Thank you!
Can I have “Lesedauer” instead of “Reading Time”? And an additional break between the headline and the reading time? An “min.” instead of “minutes”?Best regards!
- This reply was modified 5 months, 1 week ago by northorie.
June 16, 2024 at 8:06 pm #1451397Hi,
I notice that you are not using a child theme and have your customization in the parent theme functions.php
all of these customizations will be lost the next time that you update the theme.
If you are not going to use a child theme you could use the WP Code plugin then add a new snippet, in the top right corner use the PHP snippet as the code type:
and ensure that it is activated, then save.
I recommend that you move your customizations so you don’t lose them.
I changed your Reading time code to this for your last requests:function add_reading_time_to_masonry_entry($content, $entry, $config) { $reading_time_html = "<div class='reading-time'></br>" . do_shortcode('[rt_reading_time post_id="' . $entry['ID'] . '" label="Lesedauer:" postfix="min" postfix_singular="min"]') . "</div>"; $content .= $reading_time_html; return $content; } add_filter('avf_masonry_entry_title', 'add_reading_time_to_masonry_entry', 10, 3);
Best regards,
MikeJune 17, 2024 at 11:54 am #1451621Thank you too much, mike :)
I’m really happy with my site now and will look for this plugin you suggested.
Topic can be closed.Best regards!
-
AuthorPosts
- The topic ‘Reading time on blog page’ is closed to new replies.