• 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

Agentpress Pro random listings

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 › Agentpress Pro random listings

This topic is: not resolved

Tagged: AgentPress Listings, sort order

  • This topic has 19 replies, 6 voices, and was last updated 6 years, 8 months ago by Ximilis.
Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • July 2, 2015 at 3:05 pm #158222
    rtibbs4
    Participant

    Hi,

    Any way to make the featured listings on the home page show randomly instead of descending order?


    Thanks, Randy

    http://faulknercommercial.com
    July 2, 2015 at 3:33 pm #158224
    Ginger
    Participant

    Hi 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 #158279
    rtibbs4
    Participant

    Hi 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 #158309
    Ginger
    Participant

    Hi 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 #158555
    Ginger
    Participant

    Hi 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 #158557
    aan91
    Member

    thank you gingger


    Android Blog >>>> Apk Baru – Apk Gratis

    July 8, 2015 at 6:50 am #158768
    rtibbs4
    Participant

    So 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 #158771
    rtibbs4
    Participant

    So, 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 #158772
    Genesis Developer
    Member

    If you want then you can try this new plugin "Extended AgentPress Listings Widget" . It is supporting the random order.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 8, 2015 at 7:36 am #158775
    rtibbs4
    Participant

    Hi,

    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 #158777
    Genesis Developer
    Member

    the 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.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 8, 2015 at 7:53 am #158779
    Genesis Developer
    Member

    Also you will not modify the plugin's file. it is very bad habit and you can't update the plugin.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 8, 2015 at 8:11 am #158782
    rtibbs4
    Participant

    Thanks 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 #158784
    Genesis Developer
    Member

    Ok. 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

    Modifying Defaults Details

    Showing Property details

    This is for better understand.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 8, 2015 at 8:56 am #158787
    rtibbs4
    Participant

    Again, 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 #158792
    Genesis Developer
    Member

    Default AgentPress Featured Listings widget have not order option. My plugin have order option. You can order by date, title, id, random or price.


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    July 8, 2015 at 10:55 am #158809
    Ginger
    Participant

    Hi 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 #158816
    rtibbs4
    Participant

    Yeah 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 #170155
    Droid4apk
    Member

    Thanks
    http://www.rozapk.com

    July 22, 2016 at 9:23 am #190007
    Ximilis
    Member

    Just want to stop by here and say thank for this topic!! It saved me!!

  • Author
    Posts
Viewing 20 posts - 1 through 20 (of 20 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

© 2023 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