• Resolved queso

    (@queso)


    After spending much longer than I probably care to admit I finally figured out (at least it seems to be working) how to set the JSON-LD to make the Modified Date never increase.

    How can I do the same thing with the two modified meta tags? Thanks in advance!

    <meta property=”article:published_time” content=”2019-11-21T00:03:11-06:00″>
    <meta property=”article:modified_time” content=”2020-02-05T23:10:58-06:00″>
    <meta property=”og:updated_time” content=”2020-02-05T23:10:58-06:00″>

    add_filter( ‘rank_math/snippet/rich_snippet_article_entity’, function( $data ) {
    $data[‘dateModified’] = $data[‘datePublished’];
    return $data;
    }, 50, 1 );

Viewing 6 replies - 1 through 6 (of 6 total)
  • thank you!

    Plugin Author Rank Math SEO

    (@rankmath)

    Hello @queso

    Thank you for contacting the support.

    You can use the following filter to change the opengraph values:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-specific-social-meta

    Here’s the code:

    add_filter( "rank_math/opengraph/facebook/article:modified_time", function( $content ) {
    	$post = get_post();
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });
    
    add_filter( "rank_math/opengraph/facebook/og:updated_time", function( $content ) {
    	$post = get_post();
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });

    Hope that helps.

    Thread Starter queso

    (@queso)

    Yes I spent hours trying to figure out the first one using samples from the page. For us non PHP people it would definitely help not just to have the framework/shell of the function but some actual samples of a complete one. Would probably help lessen your support ticket load ??

    But anyway, I tried both codes and neither seems to be working… I tried updating the post and it just updated with the current time for both of them…

    Also threw in echo "<pre>"; print_r($post); exit; and with $content and neither page and no variable output…

    • This reply was modified 5 years, 1 month ago by queso.
    • This reply was modified 5 years, 1 month ago by queso.
    Plugin Author Rank Math SEO

    (@rankmath)

    Hello @queso

    Sorry about that.

    Can you please try this code instead?

    add_filter( "rank_math/opengraph/facebook/article_modified_time", function( $content ) {
    	global $post;
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });
    
    add_filter( "rank_math/opengraph/facebook/og_updated_time", function( $content ) {
    	global $post;
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });

    Hope that helps. Thank you.

    Thread Starter queso

    (@queso)

    Yep… it worked… Final code below for anyone else wanting to do this…

    add_filter( ‘rank_math/snippet/rich_snippet_article_entity’, function( $data ) {
    	$data[‘dateModified’] = $data[‘datePublished’];
    	return $data;
    }, 50, 1 );
    
    add_filter( "rank_math/opengraph/facebook/article_modified_time", function( $content ) {
    	global $post;
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });
    
    add_filter( "rank_math/opengraph/facebook/og_updated_time", function( $content ) {
    	global $post;
    	return mysql2date( DATE_W3C, $post->post_date, false );
    });
    Plugin Author Rank Math SEO

    (@rankmath)

    Hello @queso

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://www.ads-software.com/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Setting the modified and updated time = published?’ is closed to new replies.