Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

qdungeng on "Please help me to this code"

$
0
0
<?php
global $post;
$category = get_the_category($post->ID);
$category = $category[0]->cat_ID;
$myposts = get_posts(array('numberposts' => -1, 'category__in' => $category));
foreach($myposts as $post) :
setup_postdata($post);
?>

<?php
$field = get_field_object('hotel_in');
$value = get_field('hotel_in');
$label = $field['choices'][ $value ];
$posts = get_posts(array(
	'numberposts' => -1,
	'meta_key' => $field,
	'meta_value' => $value
));

if($posts)
{
	echo 'Hotel in ' .$label .'<ul>';

	foreach($posts as $post)
	{
		echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></li>';
	}

	echo '</ul>';
}

?>

<?php endforeach; ?>
<?php wp_reset_query(); ?>

Error to display :
Warning: trim() expects parameter 1 to be string, array given in D:\xampp\htdocs\newdh\wp-includes\meta.php on line 774
Please help me.

Thanks a lot.


Viewing all articles
Browse latest Browse all 8245

Trending Articles