php - Sortable post metabox -
i trying create sortable posts metabox. have custom post type "ba-product" in have created metabox manually select related posts , want create manually post order. stuck here how can save order metabox apply on foreach loop metabox not main posts.i don't know if possible.
<div id="related-products"> <ul id="rp-list"> <?php $products = get_posts(array('post_type' => 'ba-product', 'numberposts' => '-1', 'orderby' => 'none')); foreach($products $product) { ?> <li id="<?php echo $product->post_name.'-'.$product->id; ?>" class="related-products"> <h3 class="hndle">move</h3> <div class="inside"> <label class="selectit"> <input id="<?php echo $product->id; ?>" value="<?php echo $product->id; ?>" name="brp[rp][]" type="checkbox" /> <?php echo $product->post_title; ?> </label> </div> </li> <?php } // ends $products ?> </ul> </div>
js
jquery( document ).ready( function($) { $('#rp-list').sortable({ handle : 'h3.hndle', tolerance :'pointer', update : function () { var neworder = new array(); $('#rp-list li').each(function() { var id = $(this).attr("id"); var obj = {}; obj[id] = id; neworder.push(obj); }); $.post("post.php",{'neworder': neworder},function(data){}); } }); });
Comments
Post a Comment