-
Search Results
-
Hey Trevor,
Thanks for trying to help me this am. I have implemented the hook in functions php but it has brought on other issues now.
Issue #1 –
Current page is not recognized. So when you click page 2, it does bring load page 2 via ajax but the “current” class is not applied to the number 2 in pagination. So “1” is still treated as the current page from css standpoint thus to the user it looks like they are on page 1.Issue #2 –
The goal is for the homepage to display shows today and in future. But for the user to be able to search for all shows past and present. This is how I successfully had it set up at first. When using the below function, yes the homepage only displays shows in the future when you initially load the page but it also makes it so you can not search shows in the past. Again, the goal is for home page to display today and future shows but for the user to be able to search both past and future.function include_exclude_search_filter( $query_args, $sfid ) {
`//if search form ID = 1113, the do something with this query
if($sfid==1113)
{
//modify $query_args here before returning it
$query_args[‘meta_query’] = array(‘relation’ => ‘AND’,
array(
‘post_type’ => ‘show’,
‘posts_per_page’ => 12,
‘max_num_pages’ => 99999,
‘meta_key’ => ‘show_date’,
‘order’ => ‘ASC’,
‘orderby’ => ‘meta_value’,
),
array(
‘key’ => ‘show_date’,
‘compare’ => ‘>=’,
‘value’ => $today,
),
);
}
elseif($sfid==1234)
{}
return $query_args;
}
add_filter( ‘sf_edit_query_args’, ‘include_exclude_search_filter’, 20, 2 );`Topic: Query issues
Hey, guys!
We’re trying to display posts differently for logged in users and anonymous users (i.e. some posts are available only for logged in users). The problem is that when connecting to the ‘sf_edit_query_args_after_custom_filter’ hook the cache query is affected and the results are incomplete; the ‘sf_edit_query_args’ hook the cache works correctly but the listing displays wrong counter.
My question is: is there any hook that can alter only the results displayed so that the cache query is not affected?
Bellow is the code needed to run on the results found:function _query_filter($query_args, $sfid) { $post_type = get_query_var( 'post_type' ); $affected_post_types = array( 'module', 'learning-object', 'success-story' ); if ( !is_post_type_archive( $affected_post_types ) || is_admin() ) { return $query_args; } // echo '<pre>'; print_r( get_query_var( 'post_type' ) ); echo '</pre>'; exit; $meta_query = array( 'relation' => 'AND' ); $posts_per_page = '12'; $post_status = array( 'publish' ); if ( is_user_logged_in() ) { if ( current_user_can('partner') || current_user_can('manage_options') || ( current_user_can( 'member' ) && preg_match( '/^(\/step\/)/i', $_SERVER['REQUEST_URI'] ) ) ) { $post_status[] = 'draft'; $post_status[] = 'private'; $post_status[] = 'internal'; } } $query_args['orderby'] = 'date'; $query_args['order'] = 'DESC'; if ( $post_type != 'learning-object' ) { $posts_per_page = 6; } if ( !isset( $_GET['_sfm_language'] ) ) { $selected_language = ''; if ( !defined( 'ICL_LANGUAGE_CODE' ) ) { define( 'ICL_LANGUAGE_CODE', 'en' ); } switch ( ICL_LANGUAGE_CODE ) { case 'fi': $selected_language = 'Finnish'; break; case 'de': $selected_language = 'German'; break; default: $selected_language = 'English'; break; } // $meta_query[] = array( // 'relation' => 'OR', // array( // 'key' => 'language', // 'compare' => 'NOT EXISTS' // ), // array( // 'key' => 'language', // 'value' => $selected_language // ) // ); } if ( !is_user_logged_in() ) { $meta_query[] = array( 'relation' => 'OR', array( 'key' => 'is_public', 'compare' => 'NOT EXISTS' ), array( 'key' => 'is_public', 'value' => 'yes' ) ); } $query_args['post_status'] = $post_status; $query_args['meta_query'] = $meta_query; $query_args['posts_per_page'] = $posts_per_page; // echo '<pre>'; print_r( $query_args ); echo '</pre>'; return $query_args; } // add_filter( 'sf_edit_query_args', '_query_filter', 10, 2 ); add_filter( 'sf_edit_query_args_after_custom_filter', '_query_filter', 10, 2 );Also, how can we update the counters to reflect only the displayed results?