In this post, I will explain how you can remove/replace RankMath’s Structured Data Markup that is applied on Author Pages with your Custom Advanced Person Schema or ProfilePage Schema.
To do this we will leverage PHP Code; this code ensures to do only on that author URL that you specify & nothing else.
Go to Appearance > Theme File Editor > Functions.php
In Functions.php you need to paste this PHP Code that I am sharing below
// Custom schema for specific author URL
add_action('wp_head', 'replace_rankmath_schema', 100);
add_filter('rank_math/json_ld', 'remove_rankmath_json_ld', 99, 2);
function remove_rankmath_json_ld($data, $jsonld) {
$current_url = home_url($_SERVER['REQUEST_URI']);
$target_url = 'https://www.decodedigitalmarket.com/author/admin/';
if ($current_url === $target_url) {
return []; // Return an empty array to remove RankMath's schema
}
return $data; // Return original data for other pages
}
function replace_rankmath_schema() {
$current_url = home_url($_SERVER['REQUEST_URI']);
$target_url = 'https://www.decodedigitalmarket.com/author/admin/';
if ($current_url === $target_url) {
// Remove any existing schema
remove_all_actions('wp_head', 100);
// Your custom JSON-LD schema
$custom_schema = [
"@context" => "https://schema.org",
"@graph" => [
[
"@type" => "Organization",
"@id" => "https://www.decodedigitalmarket.com/#organization",
"name" => "Decode Digital Market"
],
[
"@type" => "WebSite",
"@id" => "https://www.decodedigitalmarket.com/#website",
"url" => "https://www.decodedigitalmarket.com",
"name" => "Decode Digital Market",
"publisher" => [
"@id" => "https://www.decodedigitalmarket.com/#organization"
],
"inLanguage" => "en"
],
[
"@type" => "Person",
"@id" => "https://www.decodedigitalmarket.com/author/admin/#person",
"name" => "Kunjal Chawhan",
"description" => "SEO Practitioner with 5+ years of experience in the industry. Has experience in working with websites catering to e-commerce, SaaS, Local Businesses, Healthcare, B2B Businesses as well as B2C business. Has familiarity of working with popular frameworks & CMS like WordPress, Shopify, Webflow, React Next JS to name a few.",
"url" => "https://www.decodedigitalmarket.com/author/admin/",
"image" => [
"@type" => "ImageObject",
"@id" => "https://www.decodedigitalmarket.com/wp-content/uploads/2021/04/uyeejxhp4pe2fl0xicuh.jpg",
"url" => "https://www.decodedigitalmarket.com/wp-content/uploads/2021/04/uyeejxhp4pe2fl0xicuh.jpg",
"caption" => "Kunjal Chawhan",
"inLanguage" => "en"
],
"sameAs" => [
"https://www.linkedin.com/in/kunjal-chawhan/",
"https://botpresso.com/author/kunjal/",
"https://x.com/kunjalchawhan",
"https://www.google.com/search?kgmid=/g/11h5p781fm"
],
"knowsAbout" => [
[
"@type" => "Thing",
"name" => "Search engine optimization",
"url" => "https://en.wikipedia.org/wiki/Search_engine_optimization"
],
[
"@type" => "Thing",
"name" => "Local search engine optimisation",
"url" => "https://en.wikipedia.org/wiki/Local_search_engine_optimisation"
],
[
"@type" => "Thing",
"name" => "Content marketing",
"url" => "https://en.wikipedia.org/wiki/Content_marketing"
],
[
"@type" => "Thing",
"name" => "Web analytics",
"url" => "https://en.wikipedia.org/wiki/Web_analytics"
]
]
],
[
"@type" => "ProfilePage",
"mainEntity" => [
"@id" => "https://www.decodedigitalmarket.com/author/admin/#person"
],
"@id" => "https://www.decodedigitalmarket.com/author/admin/#webpage",
"url" => "https://www.decodedigitalmarket.com/author/admin/",
"name" => "Kunjal Chawhan",
"author" => [
"@id" => "https://www.decodedigitalmarket.com/author/admin/#person"
],
"isPartOf" => [
"@id" => "https://www.decodedigitalmarket.com/#website"
],
"inLanguage" => "en"
]
]
];
// Output the custom schema
echo '';
}
}
You will need to make adjustments according to your Person Schema.
TL;DR
- There is a function in this PHP Code that does the job of removing RankMath’s autogenerated Schema Markup code.
- $target_url = This ensures that you’re introducing change only to the specified author URL
- Your Manual Schema can be provided within the PHP Code itself as $custom_schema
After doing this, Purge the cache, and open the author URL in the incognito tab to check if the schema has been applied correctly. Also, hit the URL in Rich Results Test to ensure that there aren’t any structured data markup issues.
![kunjal chawhan](https://www.decodedigitalmarket.com/wp-content/uploads/2021/04/uyeejxhp4pe2fl0xicuh.jpg)
Kunjal Chawhan founder of Decode Digital Market, a Digital Marketer by profession, and a Digital Marketing Niche Blogger by passion, here to share my knowledge