• Resolved bkjproductions

    (@bkjproductions)


    I had thought this was working and have been ready to deploy it across a vast empire of WP sites, but was testing a site and discovered that even though there is a sitemap.xml created, it is not being served upon request. Instead the wp-sitemap.xml (default WP sitemap, which includes the users) is returned.

    That is, mydomain.com/sitemap.xml just redirects to mydomain.com/wp-sitemap.xml

    A few thoughts:

    I have WP installed at mydomain.com/wordpress/ (as there is a need to keep WP in its own folder). However, we are redirecting the usual traffic to mydomain.com/ instead of exposing the /wordpress portion of the URL. This technique is outlined at Giving WordPress Its Own Directory: https://developer.www.ads-software.com/advanced-administration/server/wordpress-in-directory/

    That is, the WP Dashboard is at mydomain.com/wordpress/wp-admin, and the website shows up as mydomain.com/ (so /wordpress is effectively hidden for the casual visitor).

    So my current theory is that this plugin does not work in an environment where WP is in its own folder. And, when I click the “Create Sitemap” button within this plugin’s panel, the page redirects to mydomain.com/wp-admin/options-general.php?page=simpleSEOAdminOptions&sitemap_created=1
    instead of
    mydomain.com/wordpress/wp-admin/options-general.php?page=simpleSEOAdminOptions&sitemap_created=1

    (True, this could be caching or something going on. But, hear me out….)

    Likewise, if I click “Import Yoast SEO Data” the page is redirected to mydomain.com/wp-admin/admin-post.php?action=sseo_yoast_import&_wpnonce=be6122dd5d
    instead of mydomain.com/wordpress/wp-admin/admin-post.php?action=sseo_yoast_import&_wpnonce=be6122dd5d

    I’ve tried this with and without a caching plugin, and with only minimal plugins loaded, in Troubleshooting Mode and whatnot, but nothing seems to work to be able to get that /sitemap.xml to show up.

    So, I looked in the code and at around line 75 of init.php there is

    apply_filters('wp_sitemaps_enabled', false);

    which I think should be
    add_filter( 'wp_sitemaps_enabled', '__return_false' );

    I cannot find any documentation that apply_filters is the proper thing to do in this situation; usually people seem to be doing something like $myvariable = apply_filters('the_title', 'something');
    since apply_filters returns a value.

    Anyway, in my case, I think it may be more so that WP is not in the root of public_html, but instead is nestled safely into its public_html/wordpress/ folder. I suspect Sitemap.php needs a change around line 91-92ish where ABSPATH . ‘sitemap.xml’ is being used when the sitemap.xml file is written. It might be better to use get_home_path();

        file_put_contents(get_home_path().'sitemap.xml',$xmlString);
    • This topic was modified 6 months, 1 week ago by bkjproductions. Reason: some formatting
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘sitemap.xml doesn’t load’ is closed to new replies.