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

custom post meta data in search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support custom post meta data in search

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #21065
    nepatriotnepatriot
    Participant

    Hi 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?

    #21074
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    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.

    #21080
    nepatriotnepatriot
    Participant

    Hi 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/7820494281f9

    #21081
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    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;
    }
    #21082
    nepatriotnepatriot
    Participant

    Thank 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/f678fd437048

    #21083
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    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!

    #21084
    nepatriotnepatriot
    Participant

    You cannot access this content.

    #21090
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Thank 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.

    #21101
    nepatriotnepatriot
    Participant

    Awesome. Thank you. Really appreciate it. Amazing plugin. Amazing support.

    #21102
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #21103
    nepatriotnepatriot
    Participant

    You cannot access this content.

    #21104
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘custom post meta data in search’ is closed to new replies.