Support » Plugin: Yoast SEO » wpseo_sitemap_post_statuses not working

  • Resolved maidot

    (@maidot)


    I am using the function as this:

    function yoast_add_custom_status( $post_statuses, $type ) {
        $post_statuses = array( 'publish','arquivado' );
        return $post_statuses;
    }
    add_filter( 'wpseo_sitemap_post_statuses', 'yoast_add_custom_status');

    So it should work, but when I access the URL where sitemaps are generated, it says there are technical problems.

    This is urgent because this customer just stoped having thounsands (literally) of posts published inside the sitemaps.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The filter wpseo_sitemap_post_statuses works correctly. An issue is in the code. More details – https://github.com/Yoast/wordpress-seo/issues/12907 :

    First variant of the snippet could result in fatal error on newer PHP versions. You don’t need to declare second argument ($type) because your snippet don’t check specific post_type. If you want to check specific post_type then fourth argument ($accepted_args = 2) should be passed to add_filter.

    Easier snippet:

    add_filter( 'wpseo_sitemap_post_statuses', function( $post_statuses ) {
    	return array(
    		'publish',
    		'arquivado', // Your custom post_status
    	);
    } );
    

    Thank you for the answer. Yes, I actually got it working thanks to RINVIL user that quickly answered helping with the solution. 🙂

    Thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.