• Resolved GregW

    (@gwmbox)


    Is it possible to exclude a specific URL from the sitemap/indexing/following?

    I know there are settings in a page, but here I am using Ultimate Member. The member pages all use a page called Member and the data from UM is then inserted on those pages.

    So for example;

    https://mysite.com/member/username

    Since the /username is not an actual page, it just uses the ‘Member’ page settings.

    But I need to exclude some specific users.

Viewing 1 replies (of 1 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Greg!

    This should do, it’ll apply noindex to the user pages:

    add_filter( 'the_seo_framework_robots_meta_array', function( $meta, $args, $ignore ) {
    
    	if ( null === $args && function_exists( 'um_is_core_page' ) && um_is_core_page( 'user' ) ) {
    		$meta['noindex'] = 'nonindex';
    	}
    
    	return $meta;
    }, 10, 3 );

    If you want to be specific with users, then you’ll have to add more extensive calls in the filter, for example:

    if ( um_is_core_page( 'user' ) && um_get_requested_user() ) {
    	um_fetch_user( um_get_requested_user() );
    
    	// To see user() properties, peruse https://github.com/ultimatemember/ultimatemember/blob/2.1.15/includes/core/class-user.php
    	// Example: Set noindex for user ID 42.
    	if ( 42 === UM()->user()->id ) { 
    		$meta['noindex'] = 'nonindex';	
    	}
    
    	um_reset_user();
    }

    I hope this kickstarts your idea! Cheers 🙂

Viewing 1 replies (of 1 total)

The topic ‘Exclude specific URL?’ is closed to new replies.