Viewing 3 replies - 1 through 3 (of 3 total)
  • Same issue here. The ‘Include in News Sitemap’ isn’t checked by default. I remember it use to be like this quite a while ago but it didn’t work for me in the latest release of WordPress SEO. Was hoping this would include a fix for it.

    Anyone have any ideas, did the feature get removed or is it a bug?

    I figured out code to fix this, Just paste it in your functions.php.
    Not 100% tested but it also should work if you allow custom post types.

    /**
     *
     * @param int $post_id
     * @param stdClass $post
     * @return void
     */
    function publish_post_sitemap( $post_id, $post ) {
    		// only do this when a 'add new' is clicked.
    	if ( $post->post_status !== 'auto-draft' )
    		return;
    		// Is yoast on?
    	if ( !function_exists( 'get_wpseo_options' ) )
    		return;
    		// is this posttype allowed in the news sitemap?
    	$options = get_wpseo_options();
    	if ( ! isset( $options['newssitemap_include_' . $post->post_type] ) ||  $options['newssitemap_include_' . $post->post_type] !== 'on' )
    	return;
    	// set the include to ON
    	update_post_meta( $post_id, '_yoast_wpseo_newssitemap-include','on' );
    	// the checkbox should be checked after this
    }
    add_action( 'wp_insert_post', 'publish_post_sitemap', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress SEO News] Include In News Sitemap unticked by default’ is closed to new replies.