unt = 1; $wp_query->max_num_pages = 1; unset( $wp_query->query['error'] ); $wp_query->query_vars['error'] = ''; // We need to add the post object to the cache so that get_post() calls don't trigger database calls. wp_cache_add( $postId, $postObject, 'posts' ); $GLOBALS['wp_query'] = $wp_query; $wp->register_globals(); // Setting is_404 is not sufficient, so we still need to change the status code. status_header( 200 ); } /** * Get the canonical URL for the dedicated HTML sitemap page. * * @since 4.5.7 * * @param string $originalUrl The canonical URL. * @return string The canonical URL. */ public function getCanonicalUrl( $originalUrl ) { $sitemapOptions = aioseo()->options->sitemap->html; if ( ! $sitemapOptions->enable || ! $this->isDedicatedPage ) { return $originalUrl; } // If the user has set a custom URL for the sitemap page, use that. if ( $sitemapOptions->pageUrl ) { return $sitemapOptions->pageUrl; } // Return the current URL of WP. global $wp; return home_url( $wp->request ); } } } namespace { // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } if ( ! function_exists( 'aioseo_html_sitemap' ) ) { /** * Global function that can be used to print the HTML sitemap. * * @since 4.1.3 * * @param array $attributes User-defined attributes that override the default settings. * @param boolean $echo Whether to echo the output or return it. * @return string The HTML sitemap code. */ function aioseo_html_sitemap( $attributes = [], $echo = true ) { $attributes = aioseo()->htmlSitemap->frontend->getAttributes( $attributes ); return aioseo()->htmlSitemap->frontend->output( $echo, $attributes ); } } }