Community Forums › Forums › Archived Forums › Design Tips and Tricks › Agentpress Pro random listings
Tagged: AgentPress Listings, sort order
- This topic has 19 replies, 6 voices, and was last updated 8 years, 5 months ago by Ximilis.
-
AuthorPosts
-
July 2, 2015 at 3:05 pm #158222rtibbs4Participant
Hi,
Any way to make the featured listings on the home page show randomly instead of descending order?
Thanks, Randy
July 2, 2015 at 3:33 pm #158224GingerParticipantHi Randy,
This is not a theme specific question, but more of a question for the AgentPress Listings plugin support area:
https://wordpress.org/support/plugin/agentpress-listings
That said I did a quick search through the WordPress plugin repository but only found this one that appears a bit old:
https://wordpress.org/support/view/plugin-reviews/posts-order-widget
There is a way to change the sort order of the query that brings back the listings to random, but I would check with the plugin support to see if they have another solution.
@gscoolidge | Support Nerd | Website Producer/Tweaker | IDX Integrations | Hosting Options
July 3, 2015 at 6:25 am #158279rtibbs4ParticipantHi Ginger,
So, where would I go for AgentPress Listings plugin support area help? I'm confused.
Thanks, Randy
July 3, 2015 at 4:06 pm #158309GingerParticipantHi Randy, that first link in my response above is to the support area for the AgenfPress Listings support area.
@gscoolidge | Support Nerd | Website Producer/Tweaker | IDX Integrations | Hosting Options
July 6, 2015 at 3:48 pm #158555GingerParticipantHi Randy,
I stumbled across an older article on Carrie Dil's site about sorting AgentPress Listings and thought of this thread. The article for reference is here:
http://www.carriedils.com/sort-agentpress-listings-by-price/
I used her code and changed it up to sort randomly. I honestly didn't think it was that easy.
Drop this in your functions.php file:
//add random sort order to the Listings query add_action( 'pre_get_posts', 'gsc_listing_random_sort_order' ); function gsc_listing_random_sort_order( $query ) { if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'listing' ) ) { $query->set( 'orderby', 'rand' ); $query->set( 'posts_per_page', '6' ); } }
Reference link for how I learned to change the order to random. This is from the WordPress codex:
http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Hope this helps! Remember, a word of caution when editing your functions.php file -- one typo and you can cause your site to white screen so make sure you have FTP or file access.
@gscoolidge | Support Nerd | Website Producer/Tweaker | IDX Integrations | Hosting Options
July 6, 2015 at 3:54 pm #158557aan91MemberJuly 8, 2015 at 6:50 am #158768rtibbs4ParticipantSo appreciate this. I am glad I checked back because must have neglected to get email updates to this thread. I have to remember to check out Carries tips.
Thanks again
Thanks, Randy
July 8, 2015 at 7:02 am #158771rtibbs4ParticipantSo, this didn't work and I am thinking it is because I am looking for random on the home page listings which are Featured Listings? do you think that would make a difference?
And yes, thanks for the heads up on the functions file, I've been to the white screen of hell:)
Thanks, Randy
July 8, 2015 at 7:22 am #158772Genesis DeveloperMemberIf you want then you can try this new plugin "Extended AgentPress Listings Widget" . It is supporting the random order.
July 8, 2015 at 7:36 am #158775rtibbs4ParticipantHi,
I saw that option but the plugin also has the details like, bedrooms, baths, MLS# built into the plugin and we will be changing those because it doesn't fit with commercial real estate so I was thinking that could get more indepth with having to change them in the functions file and also in the plugin and then making sure it matches up.
I was hoping to simply change the the function file for this.
Thanks for your help though, I appreciate it.
Thanks, Randy
July 8, 2015 at 7:50 am #158777Genesis DeveloperMemberthe plugin also has the details like, bedrooms, baths, MLS# built into the plugin
It is not hard coded in this plugin. Those contents are populating from AgentPress Listings plugin and it is dynamic. If you are using the "agentpress_property_details" filter and altering the defaults custom field by this filter then my plugin will automatically populate this new Custom fields. So user can easily display any listing information at home page. For this reason I am giving this new option.
July 8, 2015 at 7:53 am #158779Genesis DeveloperMemberAlso you will not modify the plugin's file. it is very bad habit and you can't update the plugin.
July 8, 2015 at 8:11 am #158782rtibbs4ParticipantThanks again,
If I can't figure out how to do it in the functions file I will most likely use the plugin but my current objective is to change it in the functions file.
Thanks, Randy
July 8, 2015 at 8:19 am #158784Genesis DeveloperMemberOk. No problem. I tried this. I added the following codes in functions.php file
add_filter( 'agentpress_property_details', 'ap_property_details' ); function ap_property_details( $details ) { $details['col1'] = array( __( 'Price:', 'agentpress' ) => '_listing_price', __( 'Gross Income:', 'agentpress' ) => '_listing_grossincome', __( 'Cash Flow:', 'agentpress' ) => '_listing_cashflow', __( 'Fixtures, Furniture & Equipment:', 'agentpress' ) => '_listing_ffe', __( 'Inventory:', 'agentpress' ) => '_listing_inventory', __( 'Established:', 'agentpress' ) => '_listing_established', ); $details['col2'] = array( __( 'Listing ID#:', 'agentpress' ) => '_listing_listingis#', __( 'Business Type:', 'agentpress' ) => '_listing_businesstype', __( 'Location:', 'agentpress' ) => '_listing_location', __( 'Employees:', 'agentpress' ) => '_listing_employees', __( 'Financing:', 'agentpress' ) => '_listing_financing', __( 'Owner:', 'agentpress' ) => '_listing_owner', ); return $details; }
And Getting this
This is for better understand.
July 8, 2015 at 8:56 am #158787rtibbs4ParticipantAgain, thanks but I don't see how that gets me to displaying the featured listings on the home page
-
randomly
But great way to add additional detail for the listings.
.
Thanks, Randy
July 8, 2015 at 9:28 am #158792Genesis DeveloperMemberDefault AgentPress Featured Listings widget have not order option. My plugin have order option. You can order by date, title, id, random or price.
July 8, 2015 at 10:55 am #158809GingerParticipantHi Randy,
I figured it out, if you take out the check for the main query, it will sort all listing queries randomly. This means the featured listings widget on the homepage, and the results of the listings search bar. If you only want the homepage listings to be random, put the main query check back in and put a ! in front of it. If that doesn't make sense, let me know.
//add random sort order to the featured listings and listings search result queries add_action( 'pre_get_posts', 'gsc_listing_random_sort_order' ); function gsc_listing_random_sort_order( $query ) { if( $query->is_post_type_archive( 'listing' ) && !is_admin() ) { $query->set( 'orderby', 'rand' ); } }
@gscoolidge | Support Nerd | Website Producer/Tweaker | IDX Integrations | Hosting Options
July 8, 2015 at 11:28 am #158816rtibbs4ParticipantYeah baby! That works!
Strange, I pasted the new code and got the white screen from hell! Tried it a couple times. I pasted your previous code and it was fine as it was previously, then I made the changes to copy the second code... WORKS!
Thank you sooo much!
Thanks, Randy
November 4, 2015 at 10:58 am #170155Droid4apkMemberThanks
http://www.rozapk.comJuly 22, 2016 at 9:23 am #190007XimilisMemberJust want to stop by here and say thank for this topic!! It saved me!!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.