Support » Plugin: AgentPress Listings » Version 1.3.2 removing meta_key _listing_price_sortable

  • Resolved jkbeck


    After upgrading to 1.3.2 we noticed after editing/updating a listing it was disappearing from the home page.

    After extensive testing I’ve discovered that when clicking UPDATE from the Listing edit page the meta_key = _listing_price_sortable is removed from the Database. We use Extended AgentPress Listings Widget to display the listings in a grid and it uses _listing_price_sortable as part of the sort function so if it’s not there the listing won’t display.

    I did my testing with ALL PLUGINS DEACTIVATED except AgentPress Listings. This is entirely reproducible in my environment multiple times.

    Steps are as follows:
    1) Deactivate all plugins except AgentPress Listings version 1.3.1
    2) Go to the Listing edit page for a listing and hit UPDATE to ensure the meta key is saved to the database. Take note of the post_id in the url.
    3) Go into the database and pull up the meta_keys for that post_id. I used the following:

    SELECT * FROM 'XXXX_postmeta' where post_id IN ('8207','8142') AND meta_key IN ('_listing_city','_listing_state','_listing_price_sortable') ORDER BY post_id

    I added in a 2nd listing that I did not mess with as a control to ensure only the listing I was clicking UPDATE on was changing. At this point both listings should have meta_key for _listing_price_sortable.

    4) Deactivate 1.3.1 & activate 1.3.2
    5) Click UPDATE on the Listing Edit page for just the one listing.
    6) Run the DB script again and notice that the _listing_price_sortable meta key is now missing from the listing you clicked UPDATE on.

    Normally I would just use the 1.3.1 version until 1.3.2 was fixed or 1.3.3 came out but it seems when clicking on UPDATE listing in the 1.3.1 version the plugin is stripping out the listing video and map URLs.

    Any help on this would be appreciated!


    Edit: Added code tags

    • This topic was modified 1 year, 3 months ago by jkbeck.
    • This topic was modified 1 year, 3 months ago by jkbeck.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Excellent breakdown of the problem.

    There was a problem with the maps being deleted on update but I think that got sorted but the major problem that I have is the same as you’ve just mentioned, even the removal of a full stop and then update is clicked removes the property from the website search results.

    It seems you may have detailed the problem well enough for them to hopefully fix it – fingers crossed.

    I reset my website back to before the plugin update and it’s all OK now, I’ve just left it until they come out with 1.3.3 or whatever.

    Hopefully they’ll sort it soon enough.

    I’m a few years out of practice with PHP, but I did a diff on the version 1.3.1 & 1.3.2 files to see what changed. It seems the code for adding/removing _listing_price_sortable hasn’t changed, but the $property_details array has changed a little since the previous version.

    Perhaps the method of accessing the listing price has changed. If this is coming up false because it can’t access the data
    isset( $property_details['_listing_price']
    then the else statement will run which deletes the meta key for _listing_price_sortable.

     // Extra check for price that can create a sortable value.
    		if ( isset( $property_details['_listing_price'] ) && ! empty( $property_details['_listing_price'] ) ) {
    			$price_sortable = preg_replace( '/[^0-9\.]/', '', $property_details['_listing_price'] );
    			update_post_meta( $post_id, '_listing_price_sortable', floatval( $price_sortable ) );
    		} else {
    			delete_post_meta( $post_id, '_listing_price_sortable' );

    Here’s the $property_details array code in case someone else has an idea of how to fix this.

    		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
    		$property_details = array_map( 'wp_kses', array( wp_unslash( $_POST['ap'] ) ), array( $this->allowed_tags ) );
    		/** Store the custom fields */
    		foreach ( (array) $property_details[0] as $key => $value ) {
    			/** Save/Update/Delete */
    			if ( $value ) {
    				update_post_meta( $post->ID, $key, $value );
    			} else {
    				delete_post_meta( $post->ID, $key );
    Plugin Support Nick Cernis


    Thank you for this report and for your helpful reproduction steps and detective work, @jkbeck.

    I have filed an issue here with a suggested fix:

    The StudioPress team will look at releasing a 1.3.3 to correct this, although I don’t have a timeline for this just yet.

    I implemented your edits on my dev and live environments and all appears to be working nicely.

    Thanks for the assist!

    Plugin Support Nick Cernis


    You’re welcome, @jkbeck. Thanks for testing the fix!

    Plugin Support Nick Cernis


    AgentPress Listings 1.3.3 is now out with a fix for this issue.

    Affected site owners may need to re-save listings that have disappeared from searches or archives after upgrading.

    For those of us that have replaced the listings and are back to where we were before the update to 1.3.2 and still using version 1.3.1 of the plugin…do we just update the plugin in the normal manner?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Version 1.3.2 removing meta_key _listing_price_sortable’ is closed to new replies.