• ignitionmedia

    (@ignitionmedia)


    I have what I think is a simple request, but beyond my knowledge at the moment.

    I have to use the one template for my single post type but I need an if statement so that if the taxonomy i A, do this, else if its B do this

    Currently I have the following which works for just one taxonomy.. how do I change this so it works for both category-a & category-b (if category-a {do this} else category b {do this})

    <?php
    global $post;
    $terms = get_the_terms($post->ID, 'category-a');
    $slugs = array();
    foreach ( $terms as $term )
    $slugs[] = $term->slug;
    $other_posts = new WP_Query('post_type=accommodation&category-a='.$slugs[0].'&showposts=30&orderby=menu_order');
    if ($other_posts->have_posts()):
    while ($other_posts->have_posts()): $other_posts->the_post();
    echo "
    do stuff ";
    endwhile;
    endif;
    wp_reset_query(); ?>

    any help is appreciated

The topic ‘if else statement for taxonomy’ is closed to new replies.