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
-
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
Hi bfchris,
keep in mind, after an update of the plugin, you have to make the changes again…
best regards
pareOne 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; }Greg:
Coo! Thanks for the function! Very helpful. I’ll replace my “hack” with that.
Chris
The topic ‘Pricing Fields Sorting’ is closed to new replies.