Functions
Register a page to be included in the sitemap.
cn_register_sitemap_provider( int $id, string $name )
Note
Connections_Directory/Sitemaps/Init
action hook.Parameters
$id
- (int) (required) The post ID to create a provider for.
$name
- (string) (required) Unique name for the sitemap provider.
The$name
parameter must be characters a thru z only in all lowercase.
This is a requirement of the core WordPress sitemaps feature.
- (string) (required) Unique name for the sitemap provider.
Example
This example shows how to register page ID 10484
as a sitemaps provider for a Connections directory. This page must include the [connections]
shortcode or the Directory Block.
add_action( 'Connections_Directory/Sitemaps/Init', static function() { cn_register_sitemap_provider( 10484, 'second-directory-homepage' ); } );
Hooks
Actions
Connections_Directory/Sitemaps/Init
Filters
Connections_Directory/Sitemaps/Is_Enabled
Connections_Directory/Sitemaps/Create_Provider/Instance
Connections_Directory/Sitemaps/Homepage/Name
Connections_Directory/Sitemaps/Registry/Add_Provider
Connections_Directory/Sitemaps/Provider/URL_List
Connections_Directory/Sitemaps/Provider/Sitemap_Entry
Connections_Directory/Sitemaps/Provider/Max_Pages
Connections_Directory/Sitemaps/Provider/Query_Args
FAQs
Do I have to do anything to enable support for the sitemaps?
No, support is enabled automatically. But, there are conditions that must be met. They are as follows:
- The web host must support the native WordPress sitemap feature, which requires the SimpleXML PHP extension.
- The “Search engine visibility” option must be disabled on the WordPress Reading Settings admin page. This option is disabled by default.
- The Directory Homepage must be set on the Connections Settings admin page under the General tab. The
[connections]
shortcode must exist on the chosen page. - The “Login Required” option must be disabled on the Connections Settings admin page under the General tab. This option is disabled by default.
- The “Name” permalink option must be enabled on the Connections Settings admin page under the Advanced tab. This option is enabled by default.
This may seem like a lot of requirements, but except for setting up the Directory Homepage, all the other requirements are default settings of WordPress and Connections.
Will private and unlisted Entries be in the sitemap?
No, only the Entries that are “Public” will be found in the sitemap.
Will Entries in the Moderation queue be in the sitemap?
No, the Entries must be approved in order for them to be listed in the sitemap.
I do not want the directory Entries to be in the sitemap, how can I disable this feature?
This functionality can be disabled with a filter.
add_filter( 'Connections_Directory/Sitemaps/Is_Enabled', '__return_false' );
The filter can be added to the theme’s functions.php
file or by using the Code Snippets plugin. The latter is the recommended method.
I’ve used the [connections]
on pages other than the Directory Homepage, will those Entries exist in the sitemap?
No, by default only the Entries on Directory Homepage will be included in the sitemap. Additional pages can be registered with an action.
add_action( 'Connections_Directory/Sitemaps/Init', function() { // Change `1` (one) to the page ID of the page which should be added to the sitemap. // Change `name` to be a unique name. This must be characters a thru z only in all lowercase. // This is a requirement of the core WordPress sitemaps feature. cn_register_sitemap_provider( 1, 'name' ); } );
I do not use the core WordPress sitemaps feature. I use a plugin like Yoast SEO or Rank Math. Will Directory Entries show up in their sitemaps?
No, not at this time. Work is in progress on supporting these two SEO plugins.