This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Image in default search page

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16944
    risksoftrisksoft
    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 MarcinkoErnest 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: [php]wp_get_attachment_url( get_post_thumbnail_id($post->ID) );[/php]
    – 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.

    #16958
    risksoftrisksoft
    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,

    #16968
    Ernest MarcinkoErnest 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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.