Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Check for taxonomy archive results on search.php page
This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 6 months ago.
- AuthorPosts
- May 11, 2020 at 12:15 pm #27221
Hi,
Not really sure if this question is related to the plugin but I’m looking for a way / conditional statement to check if a search result is a taxonomy archive link.
It seems like there isn’t such a conditional statement within WordPress Core as
is_tax()
only checks if the current page is a taxonomy archive page. This might be related to the issue that taxonomy archive pages can’t be searched / shown as result with the default WordPress search.I’ve searched the Ajax Search Pro documentation but didn’t find the answer there. I found the asp_query_args filter but that filter changes the query and is not related to they way results are shown.
It there any way to check if a search result is a taxonomy archive page on the search results page (search.php)?
Kind regards,
Niels Pilon-
This topic was modified 3 years, 6 months ago by
FrisOnline76.
May 11, 2020 at 12:21 pm #27222Hi Niels,
Well, you cannot check that via WordPress core functions, as all of those items there are “mimiced” as post types, since the results page is built for that.
There might be a way though, via using the get_asp_result_field() function in there. Try:
if ( get_asp_result_field('content_type') == 'term' ) {
The “content_type” field should contain the result type – in this case you are looking for “term”, that represents taxonomy terms (taxonomy archive links).
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 11, 2020 at 12:28 pm #27224Hi Ernest,
Thanks for your quick reply which solved the issue!
Can the function also be changed to check for a specific taxonomy term as it looks like it will be used for all terms…?
Kind regards,
NielsMay 11, 2020 at 12:46 pm #27225Hi,
Well, it should return the taxonomy, if defined:
get_asp_result_field('taxonomy')
..as well as the term ID, if needed:
Best,get_asp_result_field('id')
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 11, 2020 at 12:53 pm #27226Thanks again Ernest! Issue solved 🙂
May 11, 2020 at 1:52 pm #27229You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This topic was modified 3 years, 6 months ago by
- AuthorPosts
You must be logged in to reply to this topic.