• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Conditionally add additional property details in AgentPress

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved
  • This topic has 3 replies, 2 voices, and was last updated 11 years, 1 month ago by jodzeee.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • March 24, 2014 at 11:32 pm #96518
    jodzeee
    Member

    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;
    	
    }
    
    http://www.jmwestonhomes.com/status/for-sale/
    March 26, 2014 at 11:48 am #96775
    Brad Dalton
    Participant

    Have you tried adding a conditional tag after the function?


    Tutorials for StudioPress Themes.

    March 26, 2014 at 12:53 pm #96784
    jodzeee
    Member

    No. 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 #103760
    jodzeee
    Member

    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/

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble