Community Forums › Forums › Archived Forums › Design Tips and Tricks › Conditionally add additional property details in AgentPress
- This topic has 3 replies, 2 voices, and was last updated 10 years, 8 months ago by jodzeee.
-
AuthorPosts
-
March 24, 2014 at 11:32 pm #96518jodzeeeMember
On my "available properties" page, I'd like to add another area of detail, similar to the Custom Text. Currently, I've manually added "new construction" to the image thumbnail, but I figured why not add that as a Property Detail and have it show up — this way I can put anything I want in there (e.g., Sold, Coming Soon, Available July 2014, etc.).
I got as far as adding another detail (or maybe I just changed one that was already there that I wasn't using). I called it "Status" and added it to functions.php, taxonomy.php, and archive-listing.php. I was able to style it and make it look like how I had it on the image. Cool.
But I won't always need an extra note — is there a way I can have it only show up only when I want it there?
I don't have it up on a live site right now, but in development, here's what I did in functions.php
add_filter( 'agentpress_property_details', 'agentpress_property_details_filter' ); /** * Filter the property details array. * */ function agentpress_property_details_filter( $details ) { $details['col1'] = array( __( 'Price:', 'apl' ) => '_listing_price', __( 'Address:', 'apl' ) => '_listing_address', __( 'City:', 'apl' ) => '_listing_city', __( 'State:', 'apl' ) => '_listing_state', __( 'ZIP:', 'apl' ) => '_listing_zip' ); $details['col2'] = array( __( 'Status:', 'apl' ) => '_listing_status', __( 'Square Feet:', 'apl' ) => '_listing_sqft', __( 'Bedrooms:', 'apl' ) => '_listing_bedrooms', __( 'Bathrooms:', 'apl' ) => '_listing_bathrooms', __( 'Basement:', 'apl' ) => '_listing_basement' /** __( 'MLS #:', 'apl' ) => '_listing_mls' */ ); return $details; } add_filter( 'agentpress_featured_listings_widget_loop', 'agentpress_featured_listings_widget_loop_filter' ); /** * Filter the loop output of the AgentPress Featured Listings Widget. * */ function agentpress_featured_listings_widget_loop_filter( $loop ) { $loop = ''; /** initialze the $loop variable */ $loop .= sprintf( '<a href="%s">%s</a>', get_permalink(), genesis_get_image( array( 'size' => 'properties' ) ) ); $loop .= sprintf( '<span class="listing-price">%s</span>', genesis_get_custom_field('_listing_price') ); $custom_text = genesis_get_custom_field( '_listing_text' ); if( strlen( $custom_text ) ) $loop .= sprintf( '<span class="listing-text">%s</span>', esc_html( $custom_text ) ); $loop .= sprintf( '<span class="listing-status">%s</span>', genesis_get_custom_field('_listing_status') ); $loop .= sprintf( '<span class="listing-address">%s</span>', genesis_get_custom_field('_listing_address') ); $loop .= sprintf( '<span class="listing-city-state-zip">%s %s, %s</span>', genesis_get_custom_field('_listing_city'), genesis_get_custom_field('_listing_state'), genesis_get_custom_field('_listing_zip') ); $loop .= sprintf( '<a href="%s" class="more-link">%s</a>', get_permalink(), __( 'View Listing', 'apl' ) ); return $loop; }
And taxonomy.php & archive-listings.php
http://www.jmwestonhomes.com/status/for-sale//** * Custom loop for listing archive page */ function agentpress_listing_archive_loop() { $toggle = ''; if ( have_posts() ) : while ( have_posts() ) : the_post(); $loop = ''; // init $loop .= sprintf( '<a href="%s">%s</a>', get_permalink(), genesis_get_image( array( 'size' => 'properties' ) ) ); $loop .= sprintf( '<span class="listing-price">%s</span>', genesis_get_custom_field( '_listing_price' ) ); $loop .= sprintf( '<span class="listing-text">%s</span>', genesis_get_custom_field( '_listing_text' ) ); /* $loop .= sprintf( '<span class="listing-status">%s</span>', genesis_get_custom_field( '_listing_status' ) ); */ $loop .= sprintf( '<span class="listing-address">%s</span>', genesis_get_custom_field( '_listing_address' ) ); $loop .= sprintf( '<span class="listing-city-state-zip">%s, %s %s</span>', genesis_get_custom_field( '_listing_city' ), genesis_get_custom_field( '_listing_state' ), genesis_get_custom_field('_listing_zip' ) ); $loop .= sprintf( '<a href="%s" class="more-link">%s</a>', get_permalink(), __( 'View Listing', 'agentpress' ) ); $toggle = $toggle == 'left' ? 'right' : 'left'; /** wrap in post class div, and output **/ printf( '<div class="%s"><div class="widget-wrap"><div class="listing-wrap">%s</div></div></div>', join( ' ', get_post_class( $toggle ) ), $loop ); endwhile; endif; }
March 26, 2014 at 11:48 am #96775Brad DaltonParticipantMarch 26, 2014 at 12:53 pm #96784jodzeeeMemberNo. Where exactly would it go? I'm not good at writing/understanding php, just copy/pasting and tweaking.
May 5, 2014 at 3:39 pm #103760jodzeeeMemberStill looking for some help here. I don't know how to add a conditional statement to make this happen.
On the Available Properties page, I'd like to be able to add text on top of the image. So where it currently says "under construction" (as part of the image), I'd like to be able to change it at will (e.g., sold, new listing, etc.).
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.