Fixing Agent Press

The plug in is supposed to work in conjunction with Genesis theme and be an out of the box real estate website solution that requires no coding and offer all the functionality you would need to get started as a real estate agent/agency. Unfortunately as I’m sure many have found, this is not really the case.

After much frustration and a lot of digging I wanted to share some of the modifications I have made to the Agentpress theme and Agentpress listings plugin. I hope this will save a lot of time for those who ran in to the same problems as I have.

I want to be clear that a lot of these modifications are probably not best practice and there is most probably much better ways of achieving the same results. Never the less it is working. I would be happy for anyone who has any suggestions as to how to improve these solutions to post their code here.

1: Taxonomies

Taxonomies are essentially the category fields which you associate a listing to (e.g. for sale, price range, number of beds etc)

Agentpress allows you to create custom taxonomies which you can then add to the search form through the widget section of wordpress admin.

A taxonomy has a ID and a Name which is great but I ran in to problems when adding taxonomies because the terms are are not ordered properly in the drop downs of the search menu.

I overcame this by:


  assiging ID’s to the terms such as “1″ “2″ “3″ and “a” “b” “c”


Go to Plug ins > editor > Agentpress Listings > class-property-search-widget.php

and modify get terms query as follows:

$terms = get_terms( $tax, array('hide_empty'    => false,  'orderby' => 'slug',
'order' => 'ASC', 'number' => 100, 'hierarchical' => false ) );

2. Price Ordering

This is the problem that baffles me the most – price ordering isn’t properly set up so any search returns properties with the criteria specified in the search form but completely unordered in regards to price.

This took me a long time to figure out as I couldn’t really find a thread answering it despite it being such essential functionality to a real estate agent. You can set up taxonomies for price ranges such as 1 > 2 million but then any listings which return will be unordered within that price range.

So it works like this:

The price field is a custom field which is defined in the class-listings.php file:

function __construct() {

$this->property_details = apply_filters( 'agentpress_property_details', array(
'col1' => array(
__( 'Price:', 'apl' ) => '_listing_price',

and this field is spat out in html by the listings-details-metabox.php file.

When you perform a search with no taxonomies defined you are taken to the agentpress archives.php file.

When you have defined a query and performed a search (such as number of bedrooms) it takes you to the agentpress taxonomy.php

*Note that these last two files reside in the Agentpress theme folder rather than the Agentpress Listings Plugin folder.

So there are a few mods you have to do to get the price ordering properly:


First of all you all prices need to be plain numbers with no commas, decimal points or currency symbols


Open Up archive.php and add this line of code just before the posts loop:

query_posts( "post_type=listing&".$query_string."&meta_key=_listing_price&
orderby=meta_value_num&order=ASC&posts_per_page=5" );

Here we are adding further queries to the ones already specified by the search form in and passed to the URL. *Note that I’m also specifying the number of posts per page here (modify this to your liking)

** This can’t be best practice – Im looking in to how to do this within the class-property-search-widget.php file rather than adding to the query and will eventually update this .


We then need to format the price field so that it adds in commas at the correct place and looks nice:

Open archive.php file

add these 2 lines of code

$somevariable = genesis_get_custom_field( '_listing_price' ) ;
$cleanvariable = number_format($somevariable);

just after the start of the loop  e.g.

if ( have_posts() ) : while ( have_posts() ) : the_post();

then replace:

genesis_get_custom_field( '_listing_text' )  (this appears twice in archive.php)



it should look like this for example:

$loop .= sprintf( '<span>%s AED</span>', $cleanvariable );

Note the “AED” replace this with whatever currency you wish.


Now we repeat 2.b and 2.c for taxonomy.php


Then open up class-listings.php

and just below this:

$output .= '</div><div>';
foreach ( (array) $this->property_details['col2'] as $label => $key ) {

modify the code to this:

if ($key != "_listing_price"){
$output .= sprintf( '<b>%s</b> %s<br />',
esc_html( $label ), esc_html( get_post_meta($post->ID, $key, true) ) );
else {
$output .= sprintf( '<b>%s</b> %s<br />',
esc_html( $label ), esc_html( number_format(get_post_meta($post->ID, $key, true))
."&nbsp;"."AED" ) );

This adds the currency and number formatting to the single listing page.

3. “Your search returned no results” message

in taxonomy.php add the following line of code between endwhile and endif at the bottom of the page.

else: echo 'No properties found - Please search again with different criteria';

Modify it to whatever message you want.

4. Pagination

When using the query posts function pagination is lost so we need to add this code before the last closing bracket on both archive.php and tanonomy.php:


Ok that sums up what Ive fixed so far – I hope this saves a lot of time for people!

Let me know if anyone needs any help!

  • People looking into correcting AgentPress & AgentPress Listings should also be aware of these threads:

    This pagination fix is a little different than yours, but I can verify it works:

    A couple sites that seem to implement AgentPress in a modified (i.e. fully working manner) are:

  • Hello,

    I am trying to set up Agentpress theme on my site but I am facing several difficulties with Listing search box results.

    I need some help or suggestions from you to fix these problem.

    Looking forward to your reply.


  • Hello,

    I am having a problem in agentpress listing. I follow your steps.

    i am done on the price ordered but when i try to search.. still won’t show the exact value.

    if i search $2500 – $4999 it will display everthing.

    Please help….


  • i got this error

    Warning: number_format() expects parameter 1 to be double, string given in /home/content/69/9188169/html/cedarlake/wp-content/themes/agentpress/archive-listing.php on line 25

  • Hi Marvin

    did you repeat the steps for taxonomy.php?

    Please post the archive-listing.php code so I can see what’s going on!

  • Hi Ryan, I use genesis 1.9.2 and agentpress listing. I have a custom loop that works great to display my listings but when I use the search it returns the listings using a different loop. How can I fix that? Thanks

  • Help! Just stepping into this AgentPress template ‘mess.’ Ugh! Could you please take a quick look at and enlighten me (I don’t know PHP, CSS3 or HTML)…I’m simply trying to accomplish 3 things: (1.) Present my taxonomies/search criteria in a decent form/format on the home page that’s intuitive for users/visitors under the home slider; (2.) Make my Tiny Home MLS Menu (and sub-menus) work; and (3.) Figure out how to create separate posts/entries for the “Buyers” blog and the “Sellers” blog? Thanks in advance! ~Stew

  • 1st) The reason i came across to this page is i was looking for a fix to edit the number of listing to be displayed on a set taxonomy. i had more than 10 listing tagged on a “wholesale” taxonomy i created… but only 8 is being displayed. but on 2.b i was able to set the number of listing to be displayed but only on a search result. I hope you can help me fix this one.

    2nd) I don’t know what 1.a means… like do i have to redo all my existing taxonomies?

    3rd) no. 2 and 4 is not working…
    im not sure if i placed and replaced the codes right.
    -but the price order is not working, 2.c not working… no commas showing up.
    - the custom text is not displaying anymore like it disappeared
    - the listing summary in the home page i set to 6 is not displaying correctly there are empty spaces in between.
    - im not sure if i placed the code for no.4 correctly… but how should i know? here are where i placed the codes shown below:

    ********** taxonomy.php **********

    else: echo ‘No properties found – Please search again with different criteria’;



    ********** archive.php **********

    if ( get_the_author_meta( ‘genesis_author_box_archive’, get_query_var( ‘author’ ) ) )
    genesis_author_box( ‘archive’ );


  • Ryan- just wanted to show my appreciation for your work on this. I didn’t use your code exactly as my files were slightly different but it set me on the right path to accomplish the same things. Why agentpress doesn’t have this functionality already is beyond me.

    • Hi Brian – your welcome! Thanks for the feedback! It’s a very frustrating theme to work with as I’m sure you have learned and their support is unfortunately not that great. It’s a real shame that they didn’t put the extra work in to make it easier for those that don’t know php or have the time to work out how to fix it as its supposed to make everyones life easier!

      • Ryan- any idea how to implement a custom title for property search results? No matter what someone uses for search the results page title is always ‘Listings’. Kind of stinks for SEO. It would be nice it it could be ‘Search Term’ Listings or something like that.

  • Hey Ryan,

    Thanks for this post! It was recommended by a lady in the StudioPress Forums. I was looking for a way to display a message on an AgentPress Search that displayed No Listings.

    I tried #4 from above, but couldn’t get it to work. I ended up writing a couple lines of jQuery for a nice solution. If anyone is interested: Display A Message For AgentPress Search With No Results/Listings

  • Hi Kevin! Thanks for your feedback and for sharing your solution. Normally you would approach this particular problem server side with php using an if/else statement


     if (have_posts()) 
    while (have_posts()) : the_post(); 
    // Your loop code
    else : 
    <p>sorry no results</p>
  • Hi, I really need help… I wish to choose which of the properties must appear at the home page. The order of the listings puts the first properties I have created at the bottom part and the new ones above. How do I do that? I know very little about these codes so I will truly appreciate if you can tell me where to find the codes and what to exactly do. I could not really figure it out.

    • Hi Aby

      I believe that section is controlled through the widgets > Featured Listings. I can’t remember off the top of my head but if there is not a way to set it there, or a feild to identify the property as a featured property is not present in the property edit you would have to search for the featuredlistings.php in your themes directory and modify the sql query/loop. If you don’t know coding this theme will be a waste of time – even if you know how to code its frustrating. Search for another RE theme there will be better ones!

  • Hello Ryan! Thank you for your previous answer. I have sorted it out by changing the publishing dates. However, I have another problem. I tried to understand the solutions that you gave but I am a novice in web development and I did not understand. I really need help.

    When I search for properties using the property search, it does not give me the right listings. It pulls up other property listings though I have fixed the taxonomies accordingly. Can you tell me the exact things I should do? For instance, if you look at developers and go to BUilders 2000, it is only supposed to show Newport and Venice but it is showing more properties.

  • customizing agentpress theme/plugin or trying to upgrade to 3.7/3.8, causes Agentpress listings’ property search to display results from archive-listing.php instead of taxanomy.php. Any idea what causes this?

    Issue tested here: Even starting from scratch with the original theme/plugin on 3.8 causes this change.

    Thanks for any help you can offer!

    • Hey Sarah and Abbey. There are two files associated with the search: archives.php and taxanomy.php . If you hit the search without specifying any query the archive PHP file will be called to generate the results/listings. If you select any of the fields in the drop downs and then hit search the taxanomy PHP file is used to generate the results/listings. You need to modify both files as to your desire (e.g. modify the archives.php files loop/sql query to show the most expensive apartments (as they havn’t selected anything and the taxanomy file according to your price brackets etc) hope this is of some help :)

  • Not sure if this will help Sarah or Aby but I saw a post as I was working on an AgentPress project that laid out what is controlled by which widgets on the homepage. The post is nicely presented and may be helpful, even if it’s not exactly what you’re looking for (by the very talented Carrie Dils):

  • Hi,

    Thank you so much for this, you have solve all the problems I was facing about agentpress listing. Thank you thank you.

  • Awesome tutorial – thank you! I’ve implemented and it works perfectly except I’m not getting the currency formatting. I replaced your “AED” with “USD” but I’m not getting the $ sign or commas. What am I missing?

  • The “No Properties Found” isn’t working for me, page still shows up blank.

  • I really appreciate all the work you’ve done on this and thanks for sharing it. This whole thing has been a headache – I don’t know what I’d have done if I hadn’t found your solutions.

    Can I just clarify in 2C – I’ve to replace “genesis_get_custom_field( ‘_listing_text’ )”?

    It’s not meant to be “genesis_get_custom_field( ‘_listing_price’ )” that gets replaced with $cleanvariable?

    Thanks :-)

  • I have been using the AgentPress two theme for awhile, but the one complaint I have is that I want to increase the space for the search criteria. How do I go about doing that?

1 Trackback