Conditionally add additional property details in AgentPress

Community Forums Forums Design Tips and Tricks Conditionally add additional property details in AgentPress

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  jodzeee 5 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #96518

    jodzeee
    Participant
    Post count: 231

    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

    /**
     * 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;
    	
    }
    
    • This topic was modified 7 months, 1 week ago by  jodzeee.
    • This topic was modified 7 months, 1 week ago by  jodzeee.
    http://www.jmwestonhomes.com/status/for-sale/
    #96775

    braddalton
    Participant
    Post count: 10341

    Have you tried adding a conditional tag after the function?


    #96784

    jodzeee
    Participant
    Post count: 231

    No. Where exactly would it go? I’m not good at writing/understanding php, just copy/pasting and tweaking.

    #103760

    jodzeee
    Participant
    Post count: 231

    Still 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.).

    http://www.jmwestonhomes.com/status/for-sale/

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

You must be logged in to reply to this topic.