Title: Pricing Fields Sorting
Last modified: July 29, 2017

---

# Pricing Fields Sorting

 *  Resolved [bfchris](https://wordpress.org/support/users/bfchris/)
 * (@bfchris)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/)
 * It appears that the pricing fields are listed in descending order newest>oldest,
   how can I reverse that, so the 1st pricing field I entered will appear in the
   top of the order?
 * Chris

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [bfchris](https://wordpress.org/support/users/bfchris/)
 * (@bfchris)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/#post-9363460)
 * Nevermind. I sorted this out.
    If anyone else is interested, just modify the 
   array on line 283 of /wpadverts/addons/payments/payments.php to:
 *  $pricings = new WP_Query( array(
    ‘post_type’ => ‘adverts-pricing’, ‘post_status’
   => ‘draft’, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘posts_per_page’=>-1, ) );
 * Chris
 *  [pare81](https://wordpress.org/support/users/pare81/)
 * (@pare81)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/#post-9365482)
 * Hi bfchris,
 * keep in mind, after an update of the plugin, you have to make the changes again…
 * best regards
    pare
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/#post-9366426)
 * One other way to do that without modifying plugin files would be to add the code
   below in your them functions.php (or by creating a new plugin and pasting the
   code there)
 *     ```
       add_action( "init", "my_init", 100 );
       function my_init() {
           remove_filter("adverts_form_load", "adext_payments_form_load");
           add_filter("adverts_form_load", "my_adext_payments_form_load");
       }
       function my_adext_payments_form_load( $form ) {
   
           if($form["name"] != 'advert' || is_admin() || adverts_request( "advert_id" ) ) {
               return $form;
           }
   
           // do not show payment options when editing Ad.
           $id = adverts_request( "advert_id" );
           $ad = get_post( $id );
           if( intval($id) && $ad && in_array($ad->post_status, array("publish", "expired", "pending" ) ) ) {
               return $form;
           }
   
           $form["field"][] = array(
               "name" => "_listing_information",
               "type" => "adverts_field_header",
               "order" => 1000,
               "label" => __( 'Listing Information', 'adverts' )
           );
   
           $opts = array();
           $pricings = new WP_Query( array(
               'post_type' => 'adverts-pricing',
               'post_status' => 'draft',
               'orderby' => 'ID',
               'order' => 'ASC',
               'posts_per_page'=>-1,
           ) );
   
           adverts_form_add_field("adverts_payments_field_payment", array(
               "renderer" => "adverts_payments_field_payment",
               "callback_save" => "adverts_save_single",
               "callback_bind" => "adverts_bind_single",
           ) );
   
           foreach($pricings->posts as $data) {
   
               if( get_post_meta( $data->ID, 'adverts_price', true ) ) {
                   $adverts_price = adverts_price( get_post_meta( $data->ID, 'adverts_price', true ) );
               } else {
                   $adverts_price = __("Free", "adverts");
               }
   
               $opts[] = array( "value"=>$data->ID, "text"=> $data->post_content );
           }
   
           wp_enqueue_style( 'adverts-payments-frontend' );
   
           $form["field"][] = array(
               "name" => "payments_listing_type",
               "type" => "adverts_payments_field_payment",
               "label" => __("Listing", "adverts"),
               "order" => 1001,
               "empty_option" => true,
               "options" => $opts,
               "value" => "",
               "validator" => array(
                   array( "name" => "is_required" )
               )
           );
   
           add_filter("adverts_form_bind", "adext_payments_form_bind");
   
           return $form;
       }
       ```
   
 *  Thread Starter [bfchris](https://wordpress.org/support/users/bfchris/)
 * (@bfchris)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/#post-9371438)
 * Greg:
 * Coo! Thanks for the function! Very helpful. I’ll replace my “hack” with that.
 * Chris

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Pricing Fields Sorting’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [bfchris](https://wordpress.org/support/users/bfchris/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/pricing-fields-sorting/#post-9371438)
 * Status: resolved