• Resolved dv.delian

    (@dvdelian)


    Hello!

    Is there a way of changing the meta data of posts to show “last updated” or “last modified” date instead of “published” date?

    For posts that are updated fairly often I feel that it would be much more relevant to show when the post was last updated, rather than when it was first published.

    Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @dv.delian,

    I hope you are well today and thank you for your question.

    You can try achieving this by adding the following CSS code in the Custom CSS option of your theme on the below path.

    Admin Area -> Appearance -> Customize -> Travelify Other Options

    .posted-on time.updated {
        display: inline-block;
    }
    .posted-on time.entry-date.published {
        display: none;
    }

    Best Regards,
    Movin

    Thread Starter dv.delian

    (@dvdelian)

    Thank you very much for your reply, I do think this solves what date is displayed in the posts.

    However, is there also a way of showing “last updated” date in the search engine results page (as default the published date is shown)?

    I.e. change which data the search engine picks to show in the SERP. Have been looking for where to change this code but I can’t seem to figure it out.

    Thanks again!

    /Delian

    To achieve this we will replace published date with modified date in the webpage markup and will remove the modified date markup so that the search engine will take modified date assuming it is published date.

    You can try achieving this by using the following shared custom child theme of Travelify theme that contains some custom code.

    https://drive.google.com/file/d/0B7X-aZPqO9LzUjVROVBtUGUxem8/view?usp=sharing

    Thread Starter dv.delian

    (@dvdelian)

    Thanks for your reply.

    I am currently using my own child theme for travelify. Is it sufficient to just copy the “functions.php” from your link into my child theme directory?

    Your help is highly appreciated!

    /Delian

    If you are already using the child theme of travelify theme then just add the below code in the end of functions.pgp file of your child theme.

    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function travelify_posted_on() {
    	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    	}
    	$time_string = sprintf( $time_string,
    		esc_attr( get_the_modified_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    	$byline = sprintf(
    		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
    	);
    	echo '<span class="byline"> ' . $byline . '</span><span class="posted-on">' . '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' . '</span>';
    }
    Thread Starter dv.delian

    (@dvdelian)

    Perfect, thank you very much for your support!

    /Delian

    You are most welcome here ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘post "last updated" date instead of published date’ is closed to new replies.