query for single-posttype.php – if statement needed
-
Currently I have the following query to return posts of the post_type “accommodation” in taxonomy “apartmentcat” that value is the same apartmentcat value as the page of posts they are on.
so the following works a treat..
<?php global $post; $terms = get_the_terms($post->ID, 'apartmentcat'); $slugs = array(); foreach ( $terms as $term ) $slugs[] = $term->slug; $other_posts = new WP_Query('post_type=accommodation&apartmentcat='.$slugs[0].'&showposts=30&orderby=menu_order'); if ($other_posts->have_posts()): while ($other_posts->have_posts()): $other_posts->the_post(); { do stuff } endwhile; endif; wp_reset_query(); ?>Buy now, I need to change it to an if statement so I can use one single-posttype.php template for 2 different results.
This is what I need it to do.
query post type = “accommodation”
if property_type(taxonomy) = apartment(value)
query taxonomy “apartmentcat” (same outcome as above, so if im on the Chevron Apartment page, other Chevron apartments will also show){ do stuff }
else
if property_type(taxonomy) = holiday-home(value)
query taxonomy “suburbs” (so if I’m on a Surfers holiday home page, then other Surfers holiday will also show){ do stuff }
Is anyone able to assist me with this?
The topic ‘query for single-posttype.php – if statement needed’ is closed to new replies.