[Support request] Unable to show last updated date on PAGES

Home Forums Support [Support request] Unable to show last updated date on PAGES

Home Forums Support Unable to show last updated date on PAGES

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #2503832
    Vijaykumar

    Hi
    The CSS method to show last updated date here https://docs.generatepress.com/article/show-the-updated-post-date/ is working to show last updated date for wordpress POSTS only but I am finding it hard to show the last updated date for the wordpress PAGES.

    Is there any different code for PAGES to show last updated date? Any tweak required for this css code? Or any other method?
    I tried the filter mentioned here as well https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date but it’s also not working for showing PAGE updated date.

    #2503835
    David
    Staff
    Customer Support

    Hi there,

    by default Pages do not display the entry meta, so you need to enable that to see the date.
    This doc explains:

    https://docs.generatepress.com/article/add-entry-meta-to-pages/

    #2503863
    Vijaykumar

    Thanks so much, this worked!

    #2504063
    David
    Staff
    Customer Support

    Glad to hear that

    #2505224
    Scott

    I use a different method using a custom shortcode you might find useful so i’ll share

    function post_modified_date() {
        return get_the_modified_date();
    }
    add_shortcode( 'modified_date', 'post_modified_date' );

    usage:

    Last Updated: [modified_date] to the page you desire. (I use it in a shortcode block in The gutenberg.

    #2505630
    David
    Staff
    Customer Support

    Thanks Scott!

    #2508191
    Vijaykumar

    Hi David
    I see the last updated date is shown on frontend with this change but the published date is still in the backend when we inspect the page. We want to REMOVE the published date for both posts and pages including comments. Any idea how we can remove it entirely from the page? We don’t want to show “datePublished” even in the code backend may it be added by theme or any plugin. Can this be done?

    #2508214
    Fernando
    Customer Support

    Hi Vijaykumar,

    Can you try re-adding this code?:

    add_filter( 'generate_post_date_show_updated_only', '__return_true' );

    We’ll check your post and page again afterward.

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    #2508224
    Vijaykumar

    This filter is added. Can you please check.
    Posts/pages still showing entries such as:

    class=”entry-date published” datetime=’…
    <meta property=”article:published_time” content=”..
    “datePublished”:”..

    #2508225
    Fernando
    Customer Support

    To clarify, may we know how you specifically added the snippet?

    Moreover, do you have any other code for the date aside from the one here?: https://docs.generatepress.com/article/add-entry-meta-to-pages/

    #2508245
    Vijaykumar

    Using Code snippet plugin. https://ibb.co/rMc6QyF

    #2508248
    Vijaykumar

    FYI,
    We had the code below but when we updated to PHP 8 it started giving error like undefined ‘$time_string’ error on server.

    if ( ! function_exists( 'generate_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function generate_posted_on() 
    {	
    	$date = apply_filters( 'generate_post_date', true );
    	$author = apply_filters( 'generate_post_author', true );
    	//if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) 
    		$time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
    	$time_string = sprintf( $time_string,
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_attr( get_the_modified_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    	
    	// If our date is enabled, show it
    	if ( $date ) :
    		printf( '<span style="float: left; margin-right: 3px;">Last Updated:</span><span class="posted-on">%1$s</span>',
    			sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
    				esc_url( get_permalink() ),
    				esc_attr( get_the_time() ),
    				$time_string
    			)
    		);
    	endif;
    	
    	// If our author is enabled, show it
    	if ( $author ) :
    		printf( ' <span class="byline">%1$s</span>',
    			sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>',
    				__( 'by','generatepress'),
    				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    				esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    				esc_html( get_the_author() )
    			)
    		);
    	endif;
    	
    }
    endif;
    #2508302
    David
    Staff
    Customer Support

    In regards to your reply here:
    https://generatepress.com/forums/topic/unable-to-show-last-updated-date-on-pages/#post-2508191

    When you say in the Backend – do you mean in the post/page editor ?
    Or do you mean in the websites HTML ?

    #2508381
    Vijaykumar

    Hi David
    I mean page Html when we inspect live pages and posts. I have given example urls in my first message to test links.

    We do not want to show the published date in any format on the page. I have given examples of 3 instances where it is currently being shown.

    #2508396
    David
    Staff
    Customer Support

    This is what i see in the Page URL you shared above:

    2023-01-25_11-08-57

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