0

I have the following code:

    $sortable =  false;
            'post_type' => 'tour', 
            'post_status' => 'publish',
            'posts_per_page' => -1,
            'meta_query' => array(
                array(
          $query = array( 
              'key' => 'rezdy_tour_type',
                    'value' => 'DAYTOUR'
                )
            )
        ); 

I would love to add a specific script if my rezdy_tour_type == DAYTOUR, so I've tried:

    <?php 
    global $post;
    if(get_post_meta($tour->ID, 'rezdy_tour_type', true) == 'DAYTOUR') { ?> 
    mycustomscript
    <?php 
    }
    else { ?>
    <?php 
    }
    ?>

however I am not able to create the script. Some inside help would be truly appreciated, thank you

2 Answers 2

1

Try replacing your: $tour->ID with $post->ID.

From what i see (in second code) that that $tour variable is undefined. Maybe that helps?

Sign up to request clarification or add additional context in comments.

Comments

0

I am assuming that you are finding the post list which have the DAYTOUR in their meta values. If my assumption is correct then you can use below code it should work well.

$argument= array(  'post_type' => 'tour', 
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'meta_query' => array(
                   array(
                       'key' => 'rezdy_tour_type',
                       'value' => 'DAYTOUR',
                       'compare' => '=',
                   )
                )
       );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.