Viewing 25 posts - 1 through 25 (of 25 total)
  • Author
    Posts
  • #1470510

    Is it possible for all blog posts to have a line at the bottom showing the date it was updated? Where the date automatically updates when the post is updated?

    #1470538

    Hey gatehealing,

    Thank you for the inquiry.

    Which blog layout did you select? Please provide the link to the page so we can check it.

    Best regards,
    Ismael

    #1470539

    Clarification: I mean each individual post, not the blog page that shows all posts

    Enfold Child > Blog Layout > Blog Styling > Modern Business
    Enfold Child > Blog Layout > Blog Layout > Use Advanced Layout Editor to build your own (but I cannot use ALE once I’m in there because I use the ALE for my Pages, so I’m forced to use the Default Editor for each post . . . I still do not understand why I cannot use ALE on both, but I know that it breaks something)

    Enfold Child > Blog Layout > Single Post with Big Preview Image

    Within each post > Format > Standard

    #1470544

    Hi,

    Thank you for the update.

    Try to use this filter in the functions.php file to display the modification date:

    function avf_custom_post_slider_meta_content( $meta_content, $entry, $index, $atts, $meta_array ) {
        $updated_date = get_the_modified_date( 'F j, Y', $entry->ID );
        $meta_array[] = '<div class="updated-date">Updated: ' . esc_html( $updated_date ) . '</div>';
        $meta_content = implode( '<div class="slide-meta-del">/</div>', $meta_array );
    
        return $meta_content;
    }
    
    add_filter( 'avf_post_slider_meta_content', 'avf_custom_post_slider_meta_content', 10, 5 );
    

    Best regards,
    Ismael

    #1470547

    Wow – thats nice – only if you like to get your desired MM/DD/YYYY – you should change the date format to : 'm/d/Y'

    ______________
    or if you like to have the same date format as the setting of your wordpress installation:

    function avf_custom_post_slider_meta_content( $meta_content, $entry, $index, $atts, $meta_array ) {
        $updated_date = get_the_modified_date( get_option('date_format') , $entry->ID );
        $meta_array[] = '<div class="updated-date">Updated: ' . esc_html( $updated_date ) . '</div>';
        $meta_content = implode( '<div class="slide-meta-del">/</div>', $meta_array );
        return $meta_content;
    }
    add_filter( 'avf_post_slider_meta_content', 'avf_custom_post_slider_meta_content', 10, 5 );
    #1470549

    here just a Question concerning to this – how to avoid showing on blog the date and comment count?
    The “Blog Meta Elements” show option only is working for the single blog post. Not for the blog. There the time is always displayed.
    is it because of ? :

    $show_meta_time = apply_filters( 'avf_postslider_posts_meta_data_show', true, 'time', $index, $entry, $this );
    

    same on comments. But having a child-theme postslider.php with these settings to false – will only disable time showing – but comments are still there. ?

    Edit: i only looked to the normal blog page that is created by wordpress. If i use the blog-post alb – it will have influence on both.
    Sorry

    but nevertheless : Is there a way to have a child-theme solution to show/hide these metas on blog? And not having a child-theme postslider.php

    #1470551

    Next Question : we got the filter for masonry entries: avf_masonry_loop_entry_content
    Is it possible to add via that filter new loop keys ( like the above updated date f.e.) ?

    __________
    Edit : perhaps not the most elegant method – but it works on masonry entry – and i have to find a way to only influence Masonry Entries and not masonry galleries.

    function avf_custom_masonry_loop_prepare( $key, $entries ) {
    	$separator = ' / ';
    	$updated_date = get_the_modified_date( get_option('date_format') , $key['ID'] );
    	$output .= '<span class="updated-date meta-color av-masonry-date">'.$separator.'Updated on: ' . esc_html( $updated_date ) . '</span>';
    	$key['text_after'] .= trim( $output, $separator  );
    	return $key;
    }
    add_filter( 'avf_masonry_loop_prepare', 'avf_custom_masonry_loop_prepare', 10, 2 );
    #1470611

    Sent this to my host (Dream host): After typing in the code in Appearance > Theme File Editor > functions.php, I hit Update File button and get this error: “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.” and got this reply:

    “Thank you for contacting DreamHost Support, my name is Brandon. I’m sorry
    to hear you’re having issues with WordPress, but I’ll be happy to help
    you out today. Unfortunately in this case would need to consult with the
    theme developers as its their custom code causing this issue and they
    would need to provide you with different code to add.”

    #1470616

    Hi,

    Thank you for the update.

    Did you copy the code from your email? Please try to restore the previous functions.php file, copy the code directly from this forum, then paste it to the functions.php file. Let us know if this works for you.

    Thank you for the info @Gueni007.

    Best regards,
    Ismael

    #1470618

    I copied it directly from here. It never saved it in the functions.php, so I didn’t need to restore the original. When I went back to look at it, the new code wasn’t there.

    Putting login info in private box if y’all would like to take a look.

    Thanks!
    Jon

    PS just tried it again with the same result

    • This reply was modified 2 weeks, 2 days ago by gatehealing.
    #1470620

    did you enter this in the functions.php of the parent theme? (unfortunately all this would be lost again after the next update).
    this is possible – but my recommendation is to use a child theme.

    #1470621

    No, to the child

    #1470622

    but you kept the first line of the functions.php of the child theme (<?php)
    or is there another function named avf_custom_post_slider_meta_content?
    (function names had to be unique)

    so the snippets couldn’t be the reasons for that – i always test them :
    https://webers-testseite.de/blog/. and for masonry: https://webers-testseite.de/masonry-blog/

    #1470635

    Hi,


    @gatehealing
    : We get the same error when we add the code in the functions.php file. Have you tried adding this via SFTP?

    how do i hamper the masonry-gallery to do that too. – i see that switch( $entry->post_type ) on line 1049 but can not bring it to a working snippet inclusion ( by case post or portfolio ).


    @Guenni007
    : What do you mean? The callback for the avf_masonry_loop_prepare filter that you posted above seems to be correct.

    Best regards,
    Ismael

    #1470636

    Yes – but Masonry Galleries are influenced too. I do not want image galleries to be part of that additional info.
    Only Masonry Entries should be doing that. I tried $context == 'av_masonry_entries' but again with no success.
    https://webers-testseite.de/image-masonry/

    #1470638

    Hi,

    Only Masonry Entries should be doing that. I tried $context == ‘av_masonry_entries’ but again with no success.

    Have you tried checking if the item is a post, attachment or media?

    Example:

       $post_type = get_post_type( $key['ID'] );
    
        if ($post_type === 'attachment') {
           // masonry gallery
        } else 
           // post
        }
    

    Best regards,
    Ismael

    #1470640

    the filter allows those two : ( $key, $entries )
    thats why i tried :
    if($key['post_type'] == ('post' || 'portfolio' )) { … }

    #1470641

    this seems to work:

    function avf_custom_masonry_loop_prepare( $key, $entries ) {
    	if($key['post_type'] !=  'attachment') {
    		$separator = ' / ';
    		$updated_date = get_the_modified_date( get_option('date_format') , $key['ID'] );
    		$output .= '<span class="updated-date meta-color av-masonry-date">'.$separator.'Updated on: ' . esc_html( $updated_date ) . '</span>';
    		$key['text_after'] .= trim( $output, $separator  );
    	}
        return $key;
    }
    add_filter( 'avf_masonry_loop_prepare', 'avf_custom_masonry_loop_prepare', 10, 2 );

    i do not know why the positiv check does not work ( case post or portfolio)

    Edit :
    i thought that this

    if($key['post_type'] ==  'post' || $key['post_type'] ==  'portfolio') {
    // could be shortend to:
    if($key['post_type'] ==  ('post' || 'portfolio')) {

    first one works – shortform not

    #1470642

    Hi!


    @Guenni007
    : This seems to work:

    function avf_custom_masonry_loop_prepare( $key, $entries ) {
    	$separator = ' / ';
    	$updated_date = get_the_modified_date( get_option('date_format') , $key['ID'] );
    	$output .= '<span class="updated-date meta-color av-masonry-date">'.$separator.'Updated on: ' . esc_html( $updated_date ) . '</span>';
        $post_type = get_post_type( $key['ID'] );
    
        if ($post_type !== 'attachment') {
            $key['text_after'] .= trim( $output, $separator  );
        } 
    	
    	return $key;
    }
    add_filter( 'avf_masonry_loop_prepare', 'avf_custom_masonry_loop_prepare', 10, 2 );

    Best regards,
    Ismael

    #1470644

    thanks – now i got it.

    #1470705

    wait . . . is this latest stuff for me? ie should I try that last block of code?
    Jon

    #1470711

    So the original code works when I add it in via sftp but it adds it to the Blog page, not to the bottom of the individual posts themselves, which is what I’m going for.

    #1470732

    Hi,

    wait . . . is this latest stuff for me? ie should I try that last block of code?



    @gatehealing
    : Sorry for the confusion. For single post, you may have to directly modify the includes > loop-index.php or use this filter in the functions.php file.

    add_filter('avf_post_metadata_array', function($meta, $context) {
        global $post;
    
        if($context == 'loop-index') {
            $updated_date = get_the_modified_date('F j, Y', $post->ID); 
            $meta['updated_date'] = '<span class="blog-updated-date minor-meta">Updated on: ' . $updated_date . '</span>';
        }
    
        return $meta;
    }, 10, 2);

    Best regards,
    Ismael

    #1470745

    But this works only for: non-ALB generated Posts / even Portfolios are untouched.

    #1470748

    Hi!

    @guenn007i: I think he’s using the default editor.

    Enfold Child > Blog Layout > Blog Layout > Use Advanced Layout Editor to build your own (but I cannot use ALE once I’m in there because I use the ALE for my Pages, so I’m forced to use the Default Editor for each post . . . I still do not understand why I cannot use ALE on both, but I know that it breaks something)

    // https://kriesi.at/support/topic/append-all-blog-posts-with-updated-mm-dd-yyyy/#post-1470539

    Regards,
    Ismael

Viewing 25 posts - 1 through 25 (of 25 total)
  • You must be logged in to reply to this topic.