insert a php code

Posted in: Newspaper
Post count: 50

Hello I would like to include a piece of php code in my website in order to show the time remaining for someone to read an article (which btw would be an awesome feature for your theme to implement)

the code is this <?php if (function_exists('wp_time_to_read')) wp_time_to_read(); ?>

and I would like to be shown as in the screenshots I send you

link is projectbebest.com

please have a look and let me know.

Thanks a lot

https://www.dropbox.com/s/gnf6zpzzkclutuc/Screen%20Shot%202015-12-05%20at%2020.58.33.jpg?dl=0

https://www.dropbox.com/s/kev8hzddpdndco8/Screen%20Shot%202015-12-05%20at%2021.03.24.jpg?dl=0

Post count: 7909

Hi,

You can implement this code for each post template and modules that you use – http://screencast.com/t/uZBfgLVgpyJa and for each module – http://screencast.com/t/XgosFNafyIm

Thanks!

Post count: 50

Hello, I have implemented the code and it works but I would like to achieve a slight visual modification, inside the post, most importantly to align the time reading correctly. I attach a picture to clarify my point.

pic1: https://www.dropbox.com/s/ynv1gpn3q9l2qol/Screen%20Shot%202015-12-10%20at%2016.51.34.png?dl=0

Can you help me with this one please?

Post count: 22421

Hello,
Unfortunately in it’s current state you cannot position it as it is not wrapped in any element whatsoever. Please wrap it around a div element with a custom class so you can use css to target it.
You can use the code like so:
<div class="custom-time"> <?php if (function_exists('wp_time_to_read')) wp_time_to_read();?> </div>
Then you can use a css code like so:

.custom-time{
add css code here
}

I hope this helps.

  • This reply was modified 10 years by Bogdan B..
Post count: 50

Hi, this did the trick nicely, but I have another issue now. When I put it inside a div it goes on the line below, while I would like it to have it on the same line.

Do I have to alter the css, somehow?

thanks

Post count: 22421

Hi,
You can now target your widget with css using the custom class:

.custom-time{
display:inline!important;
padding-left:5px;
vertical-align: middle;
}

Thanks.

Post count: 50

Hi, I have implemented this code, but after an update, the code was lost. Is there any way to make this code in the php file permanent?

Thanks

Post count: 23312

Hello skyscorcher,

Unfortunately, the recommended only way is to make a full backup to your site. In each update, the theme files will change and if you were changed any file that was changed in the update, your old settings will not apply because the theme overwrite the old code and you have to re-add this code in the new file changed.
For more information about backup, please consult this documentation -> https://codex.wordpress.org/WordPress_Backups

Thank you for the message!

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