Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace RankMath\Sitemap\Providers;
- defined( 'ABSPATH' ) || exit;
- class Custom implements Provider {
- public function handles_type( $type ) {
- return 'seo-glossary' === $type;
- }
- public function get_index_links( $max_entries ) {
- return [
- [
- 'loc' => \RankMath\Sitemap\Router::get_base_url( 'seo-glossary-sitemap.xml' ),
- 'lastmod' => '',
- ]
- ];
- }
- public function get_sitemap_links( $type, $max_entries, $current_page ) {
- $links = []; // Initialize the array to store the links
- $parent_permalink = get_permalink(457);
- if ($parent_permalink) {
- $links[] = [
- 'loc' => $parent_permalink,
- 'lastmod' => get_post_modified_time('c', true, 457)
- ];
- }
- $pages = get_posts(array(
- 'posts_per_page' => -1,
- 'post_type' => 'page', // Replace 'page' if you need another post type
- 'post_status' => 'publish' // Ensure only published posts are included
- ));
- foreach ($pages as $p) {
- if ($p->post_parent == 457) {
- $links[] = [
- 'loc' => get_permalink($p), // Add the page's permalink
- 'lastmod' => get_post_modified_time('c', true, $p) // Add last modified date in ISO 8601 format
- ];
- }
- }
- return $links;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement