Use ACF Field for Post Updated/Modified Time

#659109
  • Resolved ANF
    Rank Math free

    Hello Rank Math Support,
    Can you please provide instructions on how to make the og:updated_time and article:modified_time read the date and time from an ACF field?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Apologies for the delay as we currently have a high volume of tickets here in our support forums.

    To update those meta tags from your ACF field, please try using and customizing this filter on your site:

    add_filter( "rank_math/opengraph/facebook/article_modified_time", function( $content ) {
    	global $post;
    	if( 'page' == $post->post_type ) { //change to match the actual post type
    		$content = get_field('content_update_time');
    	}
    	return $content;
    });
    
    add_filter( "rank_math/opengraph/facebook/og_updated_time", function( $content ) {
    	global $post;
    	if( 'page' == $post->post_type ) { //change to match the actual post type
    	$content = get_field('content_update_time');
    }
    	return $content;
    });

    Here’s a guide to adding the code to the website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how this goes.

    Thank you.

    ANF
    Rank Math free

    Thank you Reinelle, that works perfectly!

    Hello,

    We are super happy that this resolved your issue.

    If you 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 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this ticket.