Taxonomy image on Search result

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 Ernest Marcinko 1 year ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #41342
    herbz
    herbz
    Participant

    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”

    https://prnt.sc/MPTUtzuhpoSx

    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:

    https://prnt.sc/PXRFsmFVqO9u

    https://prnt.sc/eFk1uKotanKa

    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)

    #41356
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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:

    <?php if ( !empty(get_asp_result_field('image') ): ?>
        <img src="<?php the_asp_result_field('image', true); ?>" />
    <?php endif; ?>
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41357
    herbz
    herbz
    Participant
    You cannot access this content.
    #41366
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Based on the actual results page output, you could try something like:

    <?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; ?>
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41368
    herbz
    herbz
    Participant
    You cannot access this content.
    #41369
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Unfortunaately 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 :)


    #41370
    herbz
    herbz
    Participant

    Interesting, i try it
    THANKS

    #41380
    herbz
    herbz
    Participant
    You cannot access this content.
    #41391
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Sure,

    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 :)


    #41412
    herbz
    herbz
    Participant
    You cannot access this content.
    #41422
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.