Forums Forums Search & Filter Pro Business Directory Plugin and Post Meta Searches

Viewing 7 posts - 11 through 17 (of 17 total)
  • Anonymous
    #127429
    This reply has been marked as private.
    Trevor
    #127433
    This reply has been marked as private.
    Anonymous
    #127438
    This reply has been marked as private.
    Ross Moderator
    #127573
    This reply has been marked as private.
    Anonymous
    #127577
    This reply has been marked as private.
    Anonymous
    #128682
    This reply has been marked as private.
    Ross Moderator
    #131069

    Hi Jon-Sun Lu

    Sorry for the delay on this.

    So yes, you’ve run into a limitation with S&F currently.

    Essentially, the meta key of your field, is automatically used as the name in the URL.

    So, when this getts added to the URL

    _wpbdp[fields][22]

    it would be

    _sfm__wpbdp[fields][22]

    However, even in URLs, this signifies that the $_GET var is an array called _sfm__wpbdp

    This means its not straight forward to get the value – and is not currently supported.

    We’re working on V3 of the plugin, which allows you to map the internal meta name, and create your own URL arg, but that is a while away yet.

    The only 2 options I can see are as follows:

    1) See if you can store the data from the directly plugin, in a different way, or using your own meta keys, if not, you would need to use a custom field plugin (such as ACF, PODs, or built in WP Custom field option)

    2) IF you do not plan to add tons of fields, and its only this one you are having difficulty with, what you could do is create a bit of custom code, which copies this meta value from _wpbdp[fields][22] into another custom field, with a name you choose (that doesn’t look like an array).

    I wrote a little scrip to help you get started, its untested but looks correct to me:

    //whenever a post is saved, copy the meta value, if it exists
    add_action( 'save_post', 'copy_meta_data', 100, 1 );
    function copy_meta_data($post_id)
    {
    	//remove action once its init
    	remove_action( 'save_post', 'copy_meta_data', 100, 1 );
    	
    	//grab the existing value from the DB
    	$existing_value = get_post_meta($post_id, '_wpbdp[fields][22]', true);
    	
    	//make sure it exists
    	if ( ! empty( $existing_value ) ) {
    		//now add it to a new meta key, with a name of our choosing
    		$new_meta_key = 'my_new_meta_key';
    		update_post_meta($post_id, $new_meta_key, $existing_value);
    	}
    }

    With the example above, you would then add a field to your search form, with the meta key my_new_meta_key.

    Let me know how you get on.

    Thanks

Viewing 7 posts - 11 through 17 (of 17 total)