• Resolved Richard-B

    (@richard-b)


    Hi

    We have protected various posts and other post types however we would still like to show their titles and excerpts in the standard WordPress search results. At the moment they do not appear at all.

    Is this possible?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @richard-b

    What you want is not possible with the available setting but you can try adding these snippets and see if it meets your requirement.

    add_filter( 'the_title', function($title, $id = null){
    	if(is_search()){
    		global $post;
    		return get_the_title($post->ID);
    	}
    
    	return $title;
    }
    	
    }, 11, 2 );
    
    add_filter( 'get_the_excerpt', function( $post_excerpt = '', $post = null ){
    
    	if(is_search()){
    			return $post->post_excerpt;
    	}
    
    	return $post_excerpt;
    	
    }, 9999999, 2 );

    You install this plugin and add snippet.

    Thread Starter Richard-B

    (@richard-b)

    Thank you so much, we have added that code, however it leads to a 504 error, we are using Elementor as a pagebuilder if that helps?

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @richard-b

    Please try the following Code Snippet instead:

    add_filter( 'um_ignore_restricted_title', '__return_true' );
    add_filter( 'um_ignore_restricted_excerpt', '__return_true' );

    The above code will show the title and excerpt of the restricted posts.

    Regards,

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Protected Post Previews in Search Results’ is closed to new replies.