Site logo

[Resolved] Add datePublished and dateModified to date in metadata with block elements

Home Forums Support [Resolved] Add datePublished and dateModified to date in metadata with block elements

Home Forums Support Add datePublished and dateModified to date in metadata with block elements

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2412922
    Diogenes

    Hi.

    Create a meta post following the instructions in this video of yours: https://www.youtube.com/watch?v=Ni3KXdZ5Dl8&ab_channel=GeneratePress

    I set the publication date to be replaced by the update date, when it is present.

    When I check the code I see that the microdata are not added: itemprop=”datePublished” and itemprop=”dateModified” respectively.

    I know there is an option in the Custom Attributes block that allows you to add itemprop.

    The problem is that this microdata that I add in Custom Attributes does not discriminate between the date of update and publication, and does not add them directly to the date, but to the block (container).

    Is there any possibility of adding this microdata to the publication and update date in the post meta created with block elements, and correctly discriminating them?

    I hope I have explained myself correctly.

    #2413468
    David
    Staff
    Customer Support

    Hi there,

    dynamic data in custom attributes is a really needed feature that we are working on. But its not going to be anytime soon, as it will require some refactoring of how we handle dynamic data.

    Today you could use this PHP Snippet to create a shortcode:

    
    function post_modified_date() {
    	ob_start();
    	echo generate_do_post_meta_item( 'date' );
    	return ob_get_clean();
    }
    add_shortcode( 'modified_date', 'post_modified_date' );

    Then in your Headline block you can add: modified_date

    And if you use this PHP snippet to filter the dates so the modified is displayed it will apply to that shortcode too:

    add_filter( 'generate_post_date_show_updated_only', '__return_true' );

    #2413577
    Diogenes

    Thanks David, with some adjustments it worked.

    #2413913
    David
    Staff
    Customer Support

    Glad to hear that!!

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