Able to query by trip facts?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7358
    MrOlans
    Participant

    Hello all

    Ive been trying to make a query form using wp_travel_posts_filter but add extra functionality to filter posts on trip fact value. I created a form to get the desired value but when it comes to query Im stump 🙁

    My attempt to do search.
    Please advise on what to use for $my_value ?

    Example

    
    $query->set('meta_key', 'wp_travel_trip_facts');
    $query->set('meta_query', array(
        array(
            'key' => 'wp_travel_trip_facts',
            'value' => $my_value,
            'compare' => 'LIKE',
        ),
    ));
    

    If there a better way to query against trip fact and I am incorrect?

    Apologies for my english

    #7362
    Support Team
    Keymaster

    Hello @meolans,

    First of all thank you very much for using the WP Travel plugin 🙂 .

    The feature you have mentioned is currently not available in the plugin but the feature is noted as the requested feature and will be available in the next update of the plugin. Further please let us know what type of field do you want to add in the filter widget?

    Now regarding your query about the code, we have made some changes in your code attempt and has provided the code you need to add to make the filter work with the facts.

    if ( isset( $_GET['fact'] ) ) {
    
    				$fact = $_GET['fact'];
    
    				$query->set('meta_key', 'wp_travel_trip_facts');
    				$query->set('meta_query', array(
    					array(
    						'key' => 'wp_travel_trip_facts',
    						'value' => $fact,
    						'compare' => 'LIKE',
    					),
    				));
    	
    			}

    Here you need to pass the value to the fact and to be clear on this please refer to below-given screenshot:

    https://prnt.sc/k35wto

    Hope this helps.

    Let us know if this works for you or not. If not then please provide the detail about the process you have done so that we can help you further,

    Thank you.

    Best Regards!!

    Have a good day 🙂 .

    #7382
    MrOlans
    Participant

    Great I am looking forward to that feature 🙂

    Your response was what I was looking for I only showed a part of code to make it easy for you to see
    So close I was in the solution… I had incorrect value for $fact

    Thank you for being very helpful you will be rated highly 🙂

    #7383
    Support Team
    Keymaster

    Hello @mrolans,

    Thank you very much for the effort 🙂 .

    If you face any difficulty/problem further then please let us know.

    Thank you.

    Best Regards!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘WP Travel’ is closed to new topics and replies.