Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Taxonomy image on Search result
This topic contains 10 replies, has 2 voices, and was last updated by Ernest Marcinko 1 month, 2 weeks ago.
- AuthorPosts
- February 13, 2023 at 11:44 pm #41342
Hello
i purchased the plugin Pro version, and this is what i get with the correct config on ajax search pro. For example, searching “evangelion”
but i need the same taxonomy term images on RESULTS PAGE (the page that appears when press enter on search bar after write the word). Pay atention to the red notes on screenshots:
i use the results php template. So i can modify or include any functions there.
But what is the code to get the image taxonomy there? in the example (first screenshot) the tax image is took from acf image field called “thumbnail_staff” (but it is configurated on the settings of Ajax Search Pro, so i dont know the code to output on php template)
February 14, 2023 at 1:53 pm #41356Hi,
Okay, that might be possible to do via the theme functions. Generally wordpress does not support taxonomy terms on the results page, neither the images.
Within the theme results loop, try something like this to fetch the image:
<img src="<?php the_asp_result_field('image', true); ?>" />
You may need to check for the image existence, so something like:
Best,<?php if ( !empty(get_asp_result_field('image') ): ?> <img src="<?php the_asp_result_field('image', true); ?>" /> <?php endif; ?>
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 14, 2023 at 2:12 pm #41357You cannot access this content.February 14, 2023 at 4:02 pm #41366Based on the actual results page output, you could try something like:
Best,<?php if ( !empty(get_asp_result_field('image') ): ?> <div class="img__wrap mb-3"> <a href="<?php the_asp_result_field('link', true); ?>"> <img class="img-fluid shadow-sm wp-post-image" src="<?php the_asp_result_field('image', true); ?>" /> </a> </div> <?php endif; ?>
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 14, 2023 at 4:25 pm #41368You cannot access this content.February 14, 2023 at 4:36 pm #41369Unfortunaately it is not possible to change that via that function, it only returns the data based on the plugin configuration.
In this case that would have no effect even if it is implemented, because taxonomy images are not wordpress core feature. The image is directly fetched from the field, whatever the size is of that image ID.If you use ACF, then based on this stack overflow article, you may be able to get a different size via the get_field function:
$image = get_field('image', get_asp_result_field('taxonomy') . '_' . get_asp_result_field('id')); echo '<img src="'.$image['sizes']['medium'].'" alt="$image['alt']" />';
But I don’t know if this is going to work at all, as I am not that familiar on how to properly fetch a taxonomy image via core ACF.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 14, 2023 at 4:39 pm #41370Interesting, i try it
THANKSFebruary 14, 2023 at 11:42 pm #41380You cannot access this content.February 15, 2023 at 1:11 pm #41391Sure,
1. You can change the search override method here to POST, that will keep the URL and send the arguments via a POST request. I still recommend the default GET method if possible.
2. If you choose the search bar as replacement here, then visiting the results page via URL will trigger ajax search pro via that search bar automatically.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 15, 2023 at 7:56 pm #41412You cannot access this content.February 16, 2023 at 2:42 pm #41422You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.