-
Hey there,
I’d like to create a custom sitemap that includes various real estate details that are embedded with a shortcode on a page and pulls data dynamically via a plugin / API on this page:
https://example.com/real-estate/details
This page shows up on the default page sitemap: https://example.com/page-sitemap.xml
However, all the detail pages that are pulled from the API don’t.
e.g.
https://example.com/real-estate/details/1
https://example.com/real-estate/details/2
https://example.com/real-estate/details/3
…I would like to create a custom sitemap (real estates) for those pages. I already added custom-sitemap.php in the child-theme folder with the code below and included this code in the child’s function file:
include_once ‘sitemap-custom.php’;
add_filter(‘rank_math/sitemap/providers’, function( $external_providers ) {
$external_providers[‘custom’] = new RankMathSitemapProvidersCustom();
return $external_providers;
});Perhaps RankMath cannot find the links: https://example.com/real-estate/details/* ??
<?php
namespace RankMathSitemapProviders;
defined( ‘ABSPATH’ ) || exit;
class Custom implements Provider {
public function handles_type( $type ) {
return true;
}public function get_index_links( $max_entries ) {
return [];
}public function get_sitemap_links( $type, $max_entries, $current_page ) {
$links = [
[ ‘loc’ => ‘https://example.com/real-estate/details/*’ ],];
return $links;
}}
The map does not show up. I tried other solutions from other support tickets already – without success.
I appreciate your help, thanks in advance!
Cheers,
Nils
The ticket ‘Custom Sitemap (URLs dynamically created with Plugin/API)’ is closed to new replies.