Try this code, I’ve removed query_posts
and used get_posts
instead because I’m not sure if query_posts
will work in a shortcode and using get_posts
is safer.
function featured()
{
$posts = get_posts(array('post_type' => 'property', 'posts_per_page' => 2));
if(isset($posts) && !empty($posts))
{
foreach($posts as $post)
{
echo "<div class=\"singlefeatured group\">";
//I wasn't sure what you wanted to get inside this if statement, please correct this
if ( get_post_meta($post->ID, 'pw_featured_property', true))
{
echo "<a href="".get_permalink($post->ID)."">";
echo get_the_post_thumbnail($post->ID, 'home-thumb');
echo "</a>";
}
echo "<h2><a href="".get_permalink($post->ID)."">".get_the_title($post->ID)."</a></h2>";
echo "<p>".get_post_meta($post->ID, 'pw_featured_property', true)."</p>";
echo "<p> goodbye </p>";
echo "</div>";
}
}
}
add_shortcode('featuredproperty', 'featured');
Just make sure you check what comes inside the inner if
statement, I’ve just pulled in the a
tag.