- October 23, 2018 at 3:31 pm #19593
I have used your plugin to add different post types such as Categories and Authors to the standard WordPress search results. Unfortunately all of these are returning with the same Post ID (-10) and there seems to be no way to differentiate them from other post types. This is frustrating as they all get images from different places and I am stuck without images for the non standard results. Is there anyway to fix this?
AndyOctober 24, 2018 at 10:55 am #19599
It is unfortunately neccessary to set an ‘invalid’ post ID, as otherwise wordpress would automatically treat them as post types, leading to major errors and malfunctions. I am not sure if it is possible to pass on the original ID to the results page, as objects are usually re-queried there.
I made a possible modification to the main functions file, so that it will try to pass on the original ID as a different object property. To apply this change:
1. Please open up the wp-content/plugins/ajax-search-pro/includes/functions/functions.php file on your server
2. Change it’s contents to this.
3. Save the file
Now, in your custom code, the ‘asp_id‘ property should hold the original object ID. So if the $post variable is the post object, then $post->asp_id should be the original ID.
Please note, that this may not work at all, as there is a very highy chance, that WordPress simply re-queries the post objects after the plugin passes it to it, and this information is lost then.Best,
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.