• Resolved MESS10

    (@mess10)


    Good day,

    We are currently running the astoundify theme on one of our websites. We’ve added the paid listings add on.

    The question is that we would like the listings to be ordered by the package they are part off. We currently have platinum (featured), gold and free packages.

    Currently it shows platinum at the top, because they are featured. But the gold and free listings are all mixed together. How can I achieve that it shows platinum at the top, then all gold, then all free listings?

    Also, is it possible to make the map work with gps coordinates instead of addresses?

    Many thanks in advance.

    https://www.ads-software.com/plugins/wp-job-manager/

Viewing 4 replies - 16 through 19 (of 19 total)
  • Plugin Contributor Adam Heckler

    (@adamkheckler)

    Go the wp-job-manager plugin
    Open wp-job-manager-functions.php file

    I would suggest that you avoid doing this. Changes to core files will be removed whenever WP Job Manager updates.

    The proper way to change the query args is via the filter here:

    https://github.com/Automattic/WP-Job-Manager/blob/1.23.9/wp-job-manager-functions.php#L118

    Simple example that reverses default values:

    function modify_wpjm_query_args( $query_args ) {
    	if ( ! emtpy( $query_args['orderby'] ) ) {
    		$query_args['orderby'] = array(
    			'menu_order' => 'DESC',
    			'date'       => 'ASC',
    		);
    	}
    }
    
    add_filter( 'job_manager_get_listings', 'modify_wpjm_query_args' );

    Hey,

    thanks for your answers! I finally found a workaround for my problem: I don’t need any filters! But thanks for posting the reference to the job-manager function, this is the file where I found the solution.

    WP Job Manager stores each query in transients. That means a query will be cached (in this case for 30 days). If I change one of the job listings via save_post, the cache will be flushed and the next query will contain the actual menu_order values.

    I didn’t find a solution how to prevent loading queries from the transients and my workaround is to flush the cache by saving one of the posts by hand.

    JUST in case anyone jumps into here looking for the solution like I did, you need to add

    return $query_args;

    to the end of the function that Adam posted above. Thanks for posting this fix though!

    Plugin Author Brandon Kraft

    (@kraftbj)

    Code Wrangler

    Yikes! Good catch @cirkut. Thanks for sharing.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Sorting job listings’ is closed to new replies.