Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sarahlbromley

    (@sarahlbromley)

    Got it. I appreciate the reply and your plugin!

    Thread Starter sarahlbromley

    (@sarahlbromley)

    Because I am a bad reader apparently! Thanks…I’m doing it in reverse aren’t I!

    Would also appreciate a similar filter for Property Types if it doesn’t exist. Actually filters for custom listing text, map embed code, etc would all be appreciated. I don’t want to hack the plugin and break updates, but I also want to make the admin panel as user friendly as possible for the client.

    Thanks for your valuable time. ??

    I just achieved this by modifying archive-listing.php. It doesn’t work with pagination though!

    You do have to know a bit of php, but here is the gist:

    In the function archive_listing_loop(), I moved everything that was in the while(have_posts()) loop out of it, so that it was empty. I then took that code and wrapped it in this foreach:

    foreach($listingsArray as $listing){
       //old code in the have posts loop goes here, below the have posts loop endwhile.
    }

    Then, I put this code inside the while have_posts() loop:

    $strippedPrice = preg_replace("/[^0-9.]/","",get_post_meta( $post->ID, '_listing_price', true ));
    
    			$listingsArray[$strippedPrice] = array(
    				'permalink'=> get_permalink(),
    				'thumbnail'=> get_the_post_thumbnail( $post->ID, 'listings' ),
    				'status' => wp_listings_get_status(),
    				'price' => get_post_meta( $post->ID, '_listing_price', true ),
    				'title' => get_the_title(),
    				'address' => wp_listings_get_address(),
    				'city' => wp_listings_get_city(),
    				'state' => wp_listings_get_state(),
    				'zip' => get_post_meta( $post->ID, '_listing_zip', true ),
    				'bedrooms' => get_post_meta( $post->ID, '_listing_bedrooms', true ),
    				'bathrooms' => get_post_meta( $post->ID, '_listing_bathrooms', true ),
    				'sqft' => get_post_meta( $post->ID, '_listing_sqft', true ),
    				'id' => get_the_id()
    			);

    Then, after the endwhile, I sorted the array:
    ksort($listingsArray);

    Now back down in our new foreach loop, I replaced all the instances of (for example) get_the_post_thumbnail( $post->ID, ‘listings’ ) with $listing[‘thumbnail’] etc, as you can see in the array above.

    This might be a bit tricky for some people, but just FYI, it is totally doable!

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