Change URL in schema

#301706
  • Resolved Matthias
    Rank Math free

    Hi,

    I’m getting information for a page via an API before get_header().

    I’m using custom rewrite rules to prettify GET parameters to pretty permalinks.

    So an URL which would normally look like example.com/?id=xxx
    now looks like example.com/detail/xxx/name/

    Therefore I change the title via rank_math/frontend/title filter and og:url via rank_math/opengraph/url filter.

    But I can’t find a filter to change the URL in rank-math-schema?

    Can you guide me on how to modify the schema output?

    Thanks
    Matthias

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

    Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.

    We do have a filter that will further extend the schema that is generated on the front end. Please refer to the filter code below:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 99, 2);

    More details about it from our KB page: https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi, thanks – yes I already deactivated the jsonld output like this. But basically you’re saying, if I want to replace the URLs in the output I have to str_replace() them?

    Thanks!

    Hello,

    Could you please confirm if you wish to change all the URL structures outputted by Rank Math Schema? Rank Math automatically generates the URL structure as you set it on WordPress. If the URL structure has changed by customizing it via a different method such as the custom rewrite you mentioned, then you do need to replace the URLs generated by Rank Math.

    Here’s an example of how we usually change the URLs in our schema structure manually:
    https://support.rankmath.com/ticket/change-author-url-in-article-schema/?view=all#post-239110

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Yes, that’s what I want 🙂

    Thank you!

    Hello,

    Glad that helped.

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

The ticket ‘Change URL in schema’ is closed to new replies.