Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › custom post meta data in search
- This topic has 11 replies, 2 voices, and was last updated 7 years, 3 months ago by
Ernest Marcinko.
-
AuthorPosts
-
February 11, 2019 at 6:43 pm #21065
nepatriot
ParticipantHi there,
Your plugin looks great and may just be the thing I’m looking for.
Looks like your demos are pulling custom post type info… Quick question about this… I have a table in my DB: wp_lvxafcplss_postmeta
This table has a meta_key of fw_options and a meta value of a:8:{s:13:”item_location”;a:8:{s:8:”location”;s:0:””;s:5:”venue”;s:3:”ABC”;s:7:”address”;s:32:””;s:4:”city”;s:8:”New York”;s:5:”state”;s:2:”NY”;s:7:”country”;s:13:”United States”;s:3:”zip”;s:5:”10001″;s:11:”coordinates”;a:2:{s:3:”lat”;d:;s:3:”lng”;d:;}}s:9:”1-content”;s:12:”212 803 5700″;s:9:”2-content”;s:51:”131 New York, NY 10001″;s:9:”3-content”;s:55:”Website“;s:9:”4-content”;s:22:”schizophrenic veterans”;s:16:”item_button_text”;s:7:”Website”;s:16:”item_button_link”;s:19:”http://www.website.org/”;s:16:”item_button_icon”;s:11:”fa fa-globe”;}
I need to display on search only the value: “schizophrenic veterans” — how can I make this happen?
February 12, 2019 at 11:29 am #21074Ernest Marcinko
KeymasterHi,
Thank you very much for your kind words!
Well, this looks like a serialized information stored as post meta. I tried to unserialize it to get a better view, but it wouldn’t work, so I am not sure about it’s structure. The only possible way to retrieve this is via custom code for sure, but it also depends on where you want to display this (before/after title/content etc..).
Let me know, and I will try to construct a custom code, that might be capable of retrieving this information.February 12, 2019 at 4:02 pm #21080nepatriot
ParticipantHi Ernest,
Ideally, I’d get this to show up under the title to replace the description as shown in this screenshot:
http://share.smartlighthouse.com/7820494281f9February 12, 2019 at 4:40 pm #21081Ernest Marcinko
KeymasterHi,
In that case, I constructed a custom code, that might do the trick, although I am not sure. Add this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_results', 'asp_results_cf_replacement', 10, 1); function asp_results_cf_replacement( $results ) { foreach ( $results as &$r ) { if ( isset($r->post_type) ) { $meta = get_post_meta($r->id, 'fw_options', false); if ( isset($meta, $meta['4-content']) ) { $r->content = $meta['4-content']; } } } return $results; }February 12, 2019 at 4:48 pm #21082nepatriot
ParticipantThank you for the code.
I added the code into my staging site’s child theme functions.php file and it looks like it didn’t work:
http://share.smartlighthouse.com/f678fd437048February 12, 2019 at 4:51 pm #21083Ernest Marcinko
KeymasterHi,
That means, that the data structure is probably different. Can you add temporary back-end and FTP access, so I can try debugging the code via ediging it directly? Thank you!
February 12, 2019 at 4:54 pm #21084nepatriot
ParticipantYou cannot access this content.
February 13, 2019 at 11:07 am #21090Ernest Marcinko
KeymasterThank you very much! There was a minor error within the code. Now it should display the contents of the ‘4-content’ sub field as your requested.
February 13, 2019 at 4:32 pm #21101nepatriot
ParticipantAwesome. Thank you. Really appreciate it. Amazing plugin. Amazing support.
February 13, 2019 at 4:33 pm #21102Ernest Marcinko
KeymasterYou cannot access this content.
February 13, 2019 at 4:36 pm #21103nepatriot
ParticipantYou cannot access this content.
February 13, 2019 at 4:39 pm #21104Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘custom post meta data in search’ is closed to new replies.