Title: Problem with include conditional statement
Last modified: August 21, 2016

---

# Problem with include conditional statement

 *  [cambridge15](https://wordpress.org/support/users/cambridge15/)
 * (@cambridge15)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/)
 * You’re a great plugin author, thanks for the support. Can we donate somewhere?
 * I have a new issue, I have a conditional statement setup for if the listing is
   within a certain category, if it is it’s supposed to display the bedrooms, bathrooms,
   and square footage of that category but it seems broken when preforming the UWQSF
   search.
    [http://dev.silvercreativegroup.com/op/availabilities/](http://dev.silvercreativegroup.com/op/availabilities/)
   ^ try searching for 2 bedrooms.
 * Here is my functions code,
 *     ```
       if ( $query->have_posts() ) {
       		  while ( $query->have_posts() ) {
       			$query->the_post(); global $post;
       				$query->the_post();
                                       echo  '<a href="'.get_permalink().'"><li class="availabilities-result">';
                                       echo  '<div class="availabilities-result-title">';
                                       echo  the_title();
                                       echo  '</div>';
                                       echo  '<div class="availabilities-result-image-hover">';
                                       echo  'View Listing';
                                       echo  '</div>';
                                       echo  '<div class="availabilities-result-image">';
                                       echo  get_the_post_thumbnail();
                                       echo  '</div>';
                                       echo  '<div class="availabilities-result-rent">';
                                       echo  the_field('rent');
                                       echo  '</div>';
                                       echo  '<div class="availabilities-result-avail">';
       								if( get_field('available_date') ) {
       									 echo get_field('available_date');
       									} else {
       									 echo date('m/d');
       									}
       								echo  '</div>';
                                       echo  include('conditions/availabilities-block.php');
                                       echo  '</li></a>';
       			}
       ```
   
 * And this is availabilities-block.php,
 *     ```
       <?php if ( in_category('50943') ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=308');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } elseif ( in_category('50944') ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=309');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } elseif ( in_category('50945') ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=310');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } else { ?>
   
       	<?php } ?>
       ```
   
 * [https://wordpress.org/plugins/ultimate-wp-query-search-filter/](https://wordpress.org/plugins/ultimate-wp-query-search-filter/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [TC.K](https://wordpress.org/support/users/wp_dummy/)
 * (@wp_dummy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882350)
 * Why you want to use a new query on the conditional check??
 * If I not mistaken you want to do the conditional check on each of the searched
   post, right?
    If so, it should be something like:
 *     ```
       if(in_category( '50943', $post->ID ) ){
       //blah blah blah
       }elsif(in_category( '50944', $post->ID ) ){
       //blah blah blah
       }elseif(in_category( '50945', $post->ID ) ){
       //blah blah blah
       }
       ```
   
 *  Thread Starter [cambridge15](https://wordpress.org/support/users/cambridge15/)
 * (@cambridge15)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882351)
 * I’ll try that right now, thanks TC. K.
 * Any place I can donate? You’re really helping me out.
 *  Plugin Author [TC.K](https://wordpress.org/support/users/wp_dummy/)
 * (@wp_dummy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882353)
 * Sure, you can donate at [here](http://9-sec.com/donation/). Thanks.
 *  Thread Starter [cambridge15](https://wordpress.org/support/users/cambridge15/)
 * (@cambridge15)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882359)
 * Unfortunately I’m getting the same issue, you can recreate it by searching for
   2 bedrooms here: [http://dev.silvercreativegroup.com/op/availabilities/](http://dev.silvercreativegroup.com/op/availabilities/)
 * Here’s the setup, the listings are created via an XML feed, the XML feed has 
   two main tags – <Floorplan> & <ILS_Unit>
 * The <Floorplan> has an ID that corresponds with an ID in an <ILS_Unit>
 * <Floorplan> contains the bedrooms, bathrooms, and featured image.
    <ILS_Unit>
   contains the apt title, rent, etc.
 * That’s why I have to pull that conditional statement into the results because
   I have two custom post types, one for <Floorplan> and one for <ILS_Unit> acting(
   for the end user) as one Listing.
 * I think what’s happening is my availabilities-block.php is throwing the code 
   in the functions off, closing something (or opening something) prematurely.
 * This is my updated availabilities-block.php
 *     ```
       <?php if ( in_category('50943', $post->ID) ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=308');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } elseif ( in_category('50944', $post->ID) ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=309');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } elseif ( in_category('50945', $post->ID) ) { ?>
   
       				<?php
       				$query = new WP_Query('post_type=floorplans&p=310');
       				while ( $query->have_posts() ) : $query->the_post(); ?>
   
       					<div class="availabilities-result-bedrooms"><?php the_field('bedrooms'); ?></div>
       					<div class="availabilities-result-bathrooms"><?php the_field('bathrooms'); ?></div>
       					<div class="availabilities-result-sqft"><?php the_field('sqft'); ?></div>
   
       				<?php endwhile; ?>
   
       	<?php } else { ?>
   
       	<?php } ?>
       ```
   
 * Any more ideas? Do you offer paid support, if I were to provide FTP details?
 * Thanks again for your help, I really appreciate it.
 *  Plugin Author [TC.K](https://wordpress.org/support/users/wp_dummy/)
 * (@wp_dummy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882366)
 * Yes, for hire me to help me you can contact me via [here](http://9-sec.com/hire-me/)
 *  Thread Starter [cambridge15](https://wordpress.org/support/users/cambridge15/)
 * (@cambridge15)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882368)
 * Ok, message sent successfully! My email is _[ email deleted ]_ – I think I provided
   the incorrect address on the form.. my apologizes.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Problem with include conditional statement’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ultimate-wp-query-search-filter_fcfcfc.
   svg)
 * [Ultimate WP Query Search Filter](https://wordpress.org/plugins/ultimate-wp-query-search-filter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-wp-query-search-filter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-wp-query-search-filter/reviews/)

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 6 replies
 * 2 participants
 * Last reply from: [cambridge15](https://wordpress.org/support/users/cambridge15/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/problem-with-include-conditional-statement/#post-4882368)
 * Status: not resolved