Image in default search page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Image in default search page

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16944
    risksoft
    risksoft
    Participant

    Hello,

    I’m trying to use the default WordPress search page to render the results, but for some reason I cannot retrieve the featured image. I’ve search the documentation and found the $r object, but there it is null.

    What am I missing?

    Thank you

    #16946
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I am assuming you want to display the images from across a different multisite blog?

    The plugin passes on the post objects to the results page, there is no other variable set there with the results. The image URLs are not stored within the Post object in wordpress, so this can be very difficult to get.
    You will need some sort of custom code in the results loop in the template. I would try something like:
    – Switch temporarily to the other site using: switch_to_blog
    – Then get the post featured image by id using:

    wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

    – Then switch back to the current site: restore_current_blog

    This is just the outline, it can be much more difficult than that, I am not sure if this is even possible.

    Best,
    Ernest Marcinko

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


    #16958
    risksoft
    risksoft
    Participant

    Hi Ernesto,

    Thank you for response. I think that method would help.

    What I would like to do is to change the way that the results are returned. Is there a way for example if I search for a word, all the results will be displayed in a similar way that the default search page does?

    Thank you,

    Attachments:
    You must be logged in to view attached files.
    #16968
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Do you mean, that you want to edit the layout of the live results?

    Well, it is kind of hard-coded, but you could perhaps try different themes with different layouts: https://i.imgur.com/no0njmw.png
    Maybe a horizontal or an isotopic layout theme migth better suit your needs.

    For more in-depth changes you can try the results templating, but it requires coding.

    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.