Custom php on the homepage

Posted in: Newspaper
Post count: 24

Hello,

I’m trying to add the following code to my homepage but with no luck:

<?php echo do_shortcode(' | vrijeme čitanja: < [est_time]');?>

So, the idea is to add the estimated reading time to the homepage posts loop right after the post title and date published. I’m using Page Builder – with title template & Block 6 in Visual Composer. Any idea how to get this done?

Regards,

  • This topic was modified 11 years by mm-2.
Post count: 6600

Hi,

Please make sure you add it like this: http://screencast.com/t/e6ylc5BQ
Result: http://screencast.com/t/zhjeYAGgn

Thanks

Post count: 24

Thank you for a quick response, but I’m getting only “less than a minute” result on all my posts (see the screenshot). I’ve added the same code to my loop-single.php file and it works just fine there. I’m using the https://wordpress.org/plugins/estimated-post-reading-time/ plugin to output the est. reading time. I’m not using any caching plugins.

Any clue as to why it’s not displaying properly? You can check it out at http://matijaculjak.com

Screenshot: http://i.imgur.com/pxvJb5L.png

Regards,

  • This reply was modified 11 years by mm-2.
  • This reply was modified 11 years by mm-2.
Post count: 6600

Hi,

I have tested this using the same plugin and it work fine for me: http://screencast.com/t/o3JRbcFOEUpY
I’m not sure why this is not working in your case it might be due to some plugins, you could try to deactivate all plugins and try again.
If you can’t find why this is happening I suggest you ask this on plugins support page: https://wordpress.org/support/plugin/estimated-post-reading-time

Thanks

Post count: 24

It seems like I’ll have to contact the author of the plugin, because I installed the WP from scratch, reinstalled the Newsletter theme and disabled all plugins and it still didn’t work as expected.

Although I tried several other plugins they also showed the same result (“less than a minute”).

Thank you for your help, Lucian.

Regards

  • This reply was modified 11 years by mm-2.
Post count: 24

Hello again,

it seems that the problem is in Visual Composer plugin. When I setup my homepage to display posts without the VC plugin it works correctly, but then I do not have the infinite scroll option.

Is there a way to use infinite scroll without using Page Builder that comes with Visual Composer plugin?

Regards,

Post count: 24

This is the reply I got from the plugin author:

“It’s not a plugin’s malfucntion.

The problem is that your composer has the post content as shortcodes
so a typical post content is:

[vc_row][vc_column width="2/3"][td_block6 limit=”6″
custom_title=”Posljednji članci” ajax_pagination=”infinite”
category_id=”1″ header_color=”#7bc6f1″ header_text_color=”#ffffff”
sub_cat_ajax=”n”
ajax_pagination_infinite_stop=”3″][/vc_column][vc_column
width="1/3"][vc_widget_sidebar
sidebar_id="td-top-right"][/vc_column][/vc_row]

Which is indeed a small text, so the time is less than a minute. In
order that issue to be solved, you have to search for the composer’s
documentation to see how the post content is rendered in order to use
that instead of the shortcodes one.

As you sort out how the content is displayed, you just replace the line 81 in plugin.php

$content = strip_tags($post->post_content);

with the content the plugin author give you.”

Any idea how to fix the problem or at lest how to use infinite scroll without Page Builder?

Regards,

  • This reply was modified 11 years by mm-2.
Post count: 6600

Hi,

Unfortunately the infinite scroll feature it’s available only on block which you can add just by using the VC page builder.
You could try to find a solution for this online and search for a way the get the content from the short code. You could also get a freelancer or a developer to do this for you because this is custom work and we cannot offer custom work at this time as we are working hard on development, updates and support and the time doesn’t allow us to offer custom work.
Sorry about this!

Thanks for understanding!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.