bp_search_result_page_dummy_post_load( mixed $template )
Load dummy post for wp native search result. magic starts here.
Description
Parameters
- $template
-
(Required)
Return
(mixed)
Source
File: bp-search/bp-search-filters.php
function bp_search_result_page_dummy_post_load( $template ) {
global $wp_query;
if ( ! bp_search_is_search() ) { //cancel if not search page.
return $template;
}
$dummy = array(
'ID' => 0,
'post_status' => 'public',
'post_author' => 0,
'post_parent' => 0,
'post_type' => 'page',
'post_date' => 0,
'post_date_gmt' => 0,
'post_modified' => 0,
'post_modified_gmt' => 0,
'post_content' => '',
'post_title' => '',
'post_excerpt' => '',
'post_content_filtered' => '',
'post_mime_type' => '',
'post_password' => '',
'post_name' => '',
'guid' => '',
'menu_order' => 0,
'pinged' => '',
'to_ping' => '',
'ping_status' => '',
'comment_status' => 'closed',
'comment_count' => 0,
'filter' => 'raw',
'is_404' => false,
'is_page' => false,
'is_single' => false,
'is_archive' => false,
'is_tax' => false,
'is_search' => true,
);
// Set the $post global
$post = new WP_Post( (object) $dummy );
// Copy the new post global into the main $wp_query
$wp_query->post = $post;
$wp_query->posts = array( $post );
$wp_query->post_count = 1;
$wp_query->max_num_pages = 0;
return $template;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.