0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
add_filter( 'wds_schema_printer_schema_data', 'wpturbo_add_custom_markup', 10, 2 );
function wpturbo_add_custom_markup( $data, $entity ) {
if ( ! ( $entity instanceof SmartCrawlEntitiesPost_Author ) ) {
return $data; // Not a Post Author archive.
}
// Add the URL condition here
$request_uri = $_SERVER['REQUEST_URI'];
if ( strpos( $request_uri, '/author/alana-holst' ) !== false ) {
// Edit the following:
$custom_markup = [
"@context" => "https://schema.org/",
"@type" => "Person",
"name" => "Peter Venkman",
"hasOccupation" => [
"@type" => "Occupation",
"name" => "Parapsychologist",
"educationRequirements" => "PhD in parapsychology"
]
];
$data[] = $custom_markup;
}
return $data;
}
In this updated code, we retrieve the current URL using $_SERVER['REQUEST_URI'] and check if it contains the string '/author/alana-holst'. If it does, the custom markup is added to the $data array.
Please replace the existing code in the 'wp-plugin.php' file with this updated code.
Let me know if you have any further questions!