Support

Account

Home Forums General Issues "ascend > descend" page issues

Helping

"ascend > descend" page issues

  • Hey everyone,

    I have just recently started using ACF and I am having issues with the below code to return the correct data for the page I have attached to this post. The purpose of page is for user to sort by price & view availability of properties however selecting ascend will only rearrange the properties backwards and vice verse and it seems to be returning the exact same availability for all properties which in this page is “no plots of this type available at the moment” however in other pages it may return “plot 3 available” for all properties.

    If anyone would be kind enough to have a look at the few lines and tell me if they see anything that would be great thank you.

    The link is –
    http://testing.ogilviehomes.co.uk/location/the-high-school-stirling/?house_type_by_price=true&price_order=ascending

    the code in taxonomy-locations.php is –

    <div class="tab<?php if ( $is_ht_set ) { echo ' active'; } ?>" id="house-types">
    													
    													<?php
    														if ( $is_ht_p_set ) : ?>
    														
    															<div class="house-type-tab clearfix">
    																
    																<div id="sort">
    																	<?php $ht_p_order = $_GET[ 'price_order' ]; ?>
    																	<span>Viewing Preference:</span>
    																	<select>
    																		<option<?php if ( $ht_p_order == 'descending' ) { echo ' selected'; } ?> value="descending">Highest to Lowest</option>
    																		<option<?php if ( $ht_p_order == 'ascending' ) { echo ' selected'; } ?> value="ascending">Lowest to Highest</option>
    																	</select>
    																</div>
    																
    																<article>
    																	
    																	<h3>View Properties by Price</h3>
    																	<p>The list below shows only current available properties for sale.</p>
    																	
    																</article>
    																
    																<ul class="price-list">
    											
    																	<?php 
    																	
    																		$prices = get_houses_by_price( $qo->slug );
    																		//$apartments = get_apartments_by_price( $qo->slug );
    																		//$prices = array_merge( $houses, $apartments );
    																		//echo count($prices) . '***';
    																		if ( $ht_p_order == 'descending' ) {
    																			
    																			$prices = array_reverse( $prices );
    																			
    																		}
    																		
    																		foreach ( $prices as $price ) { ?>
    																			
    																			<?php 
    																			
    																				$house_type = wp_get_post_terms( $price->ID, 'house-type' );
    																				
    																				$type = $price->taxonomy . '_';
    																				$desc = $price->description;
    																				
    																				$text = 'Return to House Type Page';
    																				$return_type = 'house_type';
    																				
    																				if ( $type == 'apartment-type_' ) {
    																					
    																					$text = 'Return to Apartment Type Page';
    																					$return_type = 'apartment-type';
    																					
    																				}
    																				
    																			?>
    																			<!--- *****   Added For loop For Houses DH -->
    																					
    																					<!--- *****   Added For loop For Houses DH-->
  • Hi @buzzbuzz,

    Thanks for the post.

    If the code is not returning the right results, probably it has something to do with incorrect data from this line:
    <?php $ht_p_order = $_GET[ 'price_order' ]; ?>

    To fix this, the first step would be to debug the value of the $ht_p_order to check if it is returning the expected results on the page like so:

    echo '<pre>';
    	var_dump( $ht_p_order );
    echo '</pre>';
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.