Support » Plugin: BuddyPress Global Search » How to use different page template instead of page.php?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support BuddyBoss Support

    (@bbwpsupport)

    Hello @m1000,

    Please follow below instructions/steps to use different page template for a search results,

    STEP – 1:

    Paste following code block into your child theme’s functions.php file.

    
    // Disable global search template override
    add_action( 'init', 'rm_buddyboss_global_search_override_wp_native_results' );
    
    /**
     * Unhook the global search template override and hook
     * custom function to override page.php template file on a search page
     */
    function rm_buddyboss_global_search_override_wp_native_results() {
    	remove_filter( 'template_include', 'buddyboss_global_search_override_wp_native_results', 999 ); //don't leave
    	add_filter( 'template_include', 'search_override_wp_native_results', 999 ); //don't leave
    }
    
    /**
     * Select the template for a search result page
     * @param $template
     * @return string
     */
    function search_override_wp_native_results( $template ) {
    	if ( is_search()  ) { //if search page.
    		
    		// Replace page.php with your template filename
    		$live_template = locate_template( array( 'buddyboss-global-search.php' ,'page.php','single.php','index.php' ) );
    
    		if ( '' != $live_template ) {
    			return $live_template;
    		}
    
    	}
    
    	return $template;
    }

    STEP – 2

    Rename the page.php with your custom template filename in above code block.

    I hope this helps! 🙂

    cool!!

    • This reply was modified 1 year, 1 month ago by  mronikoyi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use different page template instead of page.php?’ is closed to new replies.