Forums › Forums › Search & Filter Pro › Determine is search active on Post Type Archive
Tagged: first page, is_search
- This topic has 2 replies, 2 voices, and was last updated 4 years, 1 month ago by Trevor.
-
Anonymous(Private) October 2, 2020 at 2:24 pm #261737
Hi
On my taxonomy archive pages I have seo text and title that displays the title and the count for the archive then adds some content at the top and bottom of the listings.https://dev.truckpages.co.uk/trucks/for-sale/body/box/
At the moment I hide all this information if it is not the first page (used to use is_paged but found an answer you gave elsewhere and changed this to if ( !isset($_GET[‘sf_paged’]) ) :
This works fine, but I also do not want to show all the text if the user can carried out a search (in other words if there are any variables after the /body/box/ in the example above.
It is not only to hide the text, but to hide the fact that the totals count in the headline will not match the search results so will look confusing to the user.
So the query is something like… if is not first page or not have any search criteria show text else nothing.
I tried to use your ‘Check to see if anything has been filtered’ code which returns a ‘1’ even with no criteria applied in the URL (I assume because there is a filter somewhere as we are on a taxonomy archive page (box in the above example).
As an aside, I would like to add a count of the search results somewhere on the page in any case – is that possible?
ThanksJason
Anonymous(Private) October 2, 2020 at 3:35 pm #261746I have worked part of this out – hoping it won’t cause me any problems…
$expression = filter_input(INPUT_GET, '_sfm_ca-year') . $_GET['sf_paged'] ; $terms = get_the_terms( $post->ID , 'body' ); foreach ( $terms as $term ) { } if ( empty($expression)) :
Still wondering about adding an accurate count though.
Trevor(Private) October 5, 2020 at 11:34 am #261833You can write some custom code to find the filter terms in use, but it does requires some digging to find the variable names first (especially if you allow more than once choice per field), and you can find the total results count. So, this code gets the count (but you need the query variable/array name, so it might not be $query):
$number_of_results = $query->found_posts;
To figure that the variables are, you need to output the array holding the filter, then make a note of the variable names. see this post:
-
AuthorPosts