Get article application/ld data by article ID

#754983
  • Resolved Noel Ted
    Rank Math free

    How can I modify the content in application/ld based on the post ID? This is because my page loads articles at the bottom and will always load articles. When it loads, it will switch the url and head content, but currently I am encountering The problem is that the data in application/ld cannot be modified after the ajax request data comes over.

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

    I apologize for the issue you are facing with modifying the content in application/ld based on the post ID after an AJAX request. To dynamically modify the Schema Markup based on the post ID, you can use custom filters in Rank Math.

    You can add a filter to remove the Schema on specific pages like the homepage using the following code snippet:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if ( ! is_front_page() || ! isset( $data['publisher'] ) ) {
            return $data;
        }   
        unset($data['publisher']); //set the data to remove
        return $data;    
    }, 99, 2);

    This filter can be customized to meet your specific requirements. If you need further assistance in modifying the Schema based on the post ID dynamically, please feel free to contact our support team directly. We are here to help you with any customization needs.

    Thank you for reaching out with your concern.

    Sources:
    Removing Schema From Your Posts & Pages » Rank Math
    How to Use Schema Templates in Rank Math PRO » Rank Math
    How to Fix Review Schema Markup After Google’s Recent Changes?
    How to Get Your Website Listed in Google News » Rank Math

    I want to give him the article ID, or other data, and he returns the article application/ld

    Hello,

    Thank you for contacting support.

    The functions to generate Schema markup run when the page loads so it’s not possible to pass an ID to any function to get all the data.

    You need to actually load the page/post in question so that the function triggers and you can dump all the data from the filter mentioned above.

    Don’t hesitate to get in touch if you have any other questions.

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

The ticket ‘Get article application/ld data by article ID’ is closed to new replies.