-
AuthorPosts
-
July 14, 2018 at 11:36 am #985467
Dear Enfold team,
I have a question which is probably quite easy to answer for you – I tried searching the board though and couldn’t find a solution.
I’m using a php snippet which inserts the last updated date of single posts, if the updated date differs from the publishing date.
This is the snippet:
function wpds_last_updated_date( $content ) { $u_time = get_the_time('U'); $u_modified_time = get_the_modified_time('U'); if ($u_modified_time >= $u_time + 86400 && is_single() ) { $updated_date = get_the_modified_time('j. F Y'); $updated_time = get_the_modified_time('G:i'); $custom_content .= '<p class="last-updated">Zuletzt aktualisiert am '. $updated_date . ' um '. $updated_time .'</p>'; } $custom_content .= $content; return $custom_content; } add_filter( 'the_content', 'wpds_last_updated_date' );
Everything works fine on “regular” blog pages, like here – the updated date is inserted between my social sharing buttons and the first paragraph:
updated date 1But when I use the avia page builder for blog postings (which I love to do for complex layouts), the updated date gets inserted right before the first element:
avia blog postingThis updated info is really important to me – any chance to change the insertion position on avia postings?
greetings,
Ritchie- This topic was modified 6 years, 4 months ago by datadirt.
July 15, 2018 at 9:28 pm #985755Hey datadirt,
We can move it with some javascript, but the issue is that the javascript will want to move it for all pages, not just the pages you built with the advanced layout builder.
I couldn’t find a way to tell the script which page was which, and the pages share all of the same classes. Yet I my tests I didn’t find any issues with doing it this way. But I wanted you to keep an eye out for it.So, the first step is to add this code on the pages you build with the advanced layout builder, where you want the “last-updated” to show:
<div class="lastupdated"></div>
Then add this code to the end of your functions.php file in Appearance > Editor:
function custom_last_updated_script(){ ?> <script> jQuery(window).load(function(){ jQuery( ".last-updated" ).appendTo( ".lastupdated" ); }); </script> <?php } add_action('wp_footer', 'custom_last_updated_script');
The default post pages will not have the correct class, so any errors will occur there, but in my tests I found no errors.
Best regards,
MikeJuly 16, 2018 at 9:25 am #985871Dear Mike,
thank you very much!!! I could never have come up with this solution – that’s a genius idea, it works brilliantly.
Again, thanks a lot!
greetings from Vienna,
RitchieJuly 16, 2018 at 9:31 am #985874PS: I actually wrote about this updated-date snippet recently, so I took the liberty of linking your answer.
July 17, 2018 at 2:58 am #986185Hi,
Good article, thanks for sharing :)
Unless there is anything else we can assist with on this issue, shall we close this then?Best regards,
MikeJuly 17, 2018 at 9:20 am #986308Hi Mike, yes – thanks a lot again!
July 17, 2018 at 11:41 am #986362Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘Last updated date insertion / problem with avia blog postings’ is closed to new replies.