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 6 years, 6 months ago.
- AuthorPosts
- February 27, 2018 at 3:56 pm #16944
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
February 27, 2018 at 4:27 pm #16946Hi,
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 :)
February 28, 2018 at 10:52 am #16958Hi 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.March 1, 2018 at 10:29 am #16968Hi!
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 :)
- AuthorPosts
You must be logged in to reply to this topic.