buddyboss_global_search_result_page_dummy_post_load

The BuddyPress Global Search buddyboss global search result page dummy post load function.

Description

buddyboss_global_search_result_page_dummy_post_load( $template ); 

Parameters (1)

0. $template
The template.

Usage

  1. if ( !function_exists( 'buddyboss_global_search_result_page_dummy_post_load' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-global-search/includes/filters.php'; 
  3.  
  4. // The template. 
  5. $template = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = buddyboss_global_search_result_page_dummy_post_load($template); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/filters.php  
  1. function buddyboss_global_search_result_page_dummy_post_load($template) { 
  2. global $wp_query; 
  3.  
  4. if(!is_search()) { //cancel if not search page. 
  5. return $template;  
  6.  
  7. $dummy = array( 
  8. 'ID' => 0,  
  9. 'post_status' => 'public',  
  10. 'post_author' => 0,  
  11. 'post_parent' => 0,  
  12. 'post_type' => 'page',  
  13. 'post_date' => 0,  
  14. 'post_date_gmt' => 0,  
  15. 'post_modified' => 0,  
  16. 'post_modified_gmt' => 0,  
  17. 'post_content' => '',  
  18. 'post_title' => __('Search Results', "buddypress-global-search"),  
  19. 'post_excerpt' => '',  
  20. 'post_content_filtered' => '',  
  21. 'post_mime_type' => '',  
  22. 'post_password' => '',  
  23. 'post_name' => '',  
  24. 'guid' => '',  
  25. 'menu_order' => 0,  
  26. 'pinged' => '',  
  27. 'to_ping' => '',  
  28. 'ping_status' => '',  
  29. 'comment_status' => 'closed',  
  30. 'comment_count' => 0,  
  31. 'filter' => 'raw',  
  32. 'is_404' => false,  
  33. 'is_page' => false,  
  34. 'is_single' => false,  
  35. 'is_archive' => false,  
  36. 'is_tax' => false,  
  37. 'is_search' => true,  
  38. ); 
  39. // Set the $post global 
  40. $post = new WP_Post( (object) $dummy ); 
  41.  
  42. // Copy the new post global into the main $wp_query 
  43. $wp_query->post = $post; 
  44. $wp_query->posts = array( $post ); 
  45. $wp_query->post_count = 1; 
  46. $wp_query->max_num_pages = 0; 
  47.  
  48. return $template;