Reputation: 47
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
Upvotes: 0
Views: 22
Reputation: 236
Try replacing your: $tour->ID with $post->ID.
From what i see (in second code) that that $tour variable is undefined. Maybe that helps?
Upvotes: 1
Reputation: 3514
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' => '=',
)
)
);
Upvotes: 0