Add Date Property in JobPosting schema

#907875
  • Resolved M Bilal Mirza
    Rank Math free

    I’m currently using the RankMath JobPosting schema and utilizing the %date(Y-m-dTH:i:sP)% shortcode to display the post date in the schema markup. Recently, I created a custom function to update only the post’s modified date, while keeping the original publish date unchanged.

    I would like to know how I can modify the schema to display the post’s modified date instead of the publish date. Could you guide me on how to achieve this?

    For this I’m using this code:


    add_filter( 'rank_math/snippet/rich_snippet_jobposting_entity', function( $entity ) {
    if(isset($entity['datePosted'])){
    $entity['datePosted'] = get_the_modified_time('Y-m-dTH:i:sP');
    }
    return $entity;
    });

    It displays dateModified in schema but Now I want to display both datePosted and modifiedDate peoperty separately in JobPosting Schema. What should I do to get it done

Viewing 1 replies (of 1 total)
  • Hello,

    I apologize for the issue you are facing. To display both datePosted and dateModified properties separately in the JobPosting schema using Rank Math, you can modify your existing filter function to include both properties. Here’s how you can do it:

    add_filter( 'rank_math/snippet/rich_snippet_jobposting_entity', function( $entity ) {
        if ( isset( $entity['datePosted'] ) ) {
            // Set the datePosted to the original publish date
            $entity['datePosted'] = get_the_date('Y-m-dTH:i:sP');
        }
        // Set the dateModified to the modified date
        $entity['dateModified'] = get_the_modified_time('Y-m-dTH:i:sP');
        return $entity;
    });

    In this code:

    • The datePosted property is set to the original publish date using get_the_date().
    • The dateModified property is set to the modified date using get_the_modified_time().

    This way, both properties will be included in your JobPosting schema markup.

    If you have any further questions or need additional assistance, feel free to ask!

    Sources:
    JobPosting Schema Type » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Add Date Property in JobPosting schema’ is closed to new replies.