Fixes wrong redirection of search params. (https://github.com/tainacan/tainacan/issues/428)

This commit is contained in:
mateuswetah 2020-11-05 15:29:13 -03:00
parent 18ce89b233
commit 420a4449e8
1 changed files with 19 additions and 10 deletions

View File

@ -192,7 +192,15 @@ add_action( 'admin_head', 'tainacan_customize_editor_css');
*/ */
function tainacan_include_items_in_search_results( $query ) { function tainacan_include_items_in_search_results( $query ) {
if ( defined ('TAINACAN_VERSION') && $query->get( 'post_type' ) !== 'tainacan-collection' && (!isset($_GET['onlyposts']) || !$_GET['onlyposts']) && (!isset($_GET['onlypages']) || !$_GET['onlypages']) && $query->is_main_query() && $query->is_search() && ! is_admin()) { if ( !is_post_type_archive() && isset($_GET['s']) ) {
if ( defined ('TAINACAN_VERSION') &&
$query->get( 'post_type' ) !== 'tainacan-collection' &&
(!isset($_GET['onlyposts']) || !$_GET['onlyposts']) &&
(!isset($_GET['onlypages']) || !$_GET['onlypages']) &&
$query->is_main_query() &&
$query->is_search() &&
!is_admin()
) {
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
$existing_post_types = $query->get( 'post_type' ); $existing_post_types = $query->get( 'post_type' );
@ -206,6 +214,7 @@ function tainacan_include_items_in_search_results( $query ) {
$query->set( 'post_type', 'post' ); $query->set( 'post_type', 'post' );
} }
} }
}
add_action( 'pre_get_posts', 'tainacan_include_items_in_search_results' ); add_action( 'pre_get_posts', 'tainacan_include_items_in_search_results' );
/** /**