WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO News
Include In News Sitemap unticked by default (4 posts)

  1. Caspar Aremi
    Member
    Posted 1 year ago #

    I've installed this new version of the News sitemap extension which seems to work - but only if our authors or editors remember to tick 'Include in News Sitemap' in the SEO options panel on the article edit page.

    Is this just me or it is a problem with the plugin?

    Thanks

    Caspar

    http://wordpress.org/extend/plugins/wordpress-seo-news/

  2. drivenfaroff
    Member
    Posted 1 year ago #

    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?

  3. Aahan Krish
    Member
    Posted 1 year ago #

  4. janw.oostendorp
    Member
    Posted 1 year ago #

    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 );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.