Hello,
We apologize for the issue you are facing. To modify the JobPosting schema in Rank Math to display the post’s modified date instead of the publish date, you will need to customize the schema output using a filter.
Here’s a general approach you can take:
-
Add a Custom Function: You can add a custom function in your theme’s functions.php
file to modify the schema output. Use the rank_math/json_ld/job_posting
filter to change the date.
-
Use the Modified Date: In your custom function, retrieve the modified date using get_the_modified_time()
and set it in the schema.
Here’s an example of how you might implement this:
add_filter('rank_math/json_ld/job_posting', function($data) {
if (isset($data['datePosted'])) {
$data['datePosted'] = get_the_modified_time('Y-m-dTH:i:sP');
}
return $data;
});
This code checks if the datePosted
key exists in the JobPosting schema and replaces it with the modified date.
- Save Changes: After adding this code, save your changes and check your schema output to ensure that the modified date is now being used.
If you have any further questions or need assistance with this implementation, please feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further.
Thank you for raising this concern!
Sources:
How to Change the Date & Time on Your Posts/Pages » Rank Math
It didn’t works. it still shows the post date which is unchanged
Hello,
Could you please share the affected URL where the jobPosting schema is applied so we can check?
Meanwhile, please try this filter and check if the date is already correct:
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;
});
You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how this goes.
Thanks Buddy! it works !!!
Hello,
We are glad to hear that this issue has been resolved. Thank you for letting us know. This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.
We appreciate your patience and cooperation throughout this process.
Thank you for choosing Rank Math.