简体   繁体   中英

Jquery sortable function is not working in wordpress

Here is my code

jQuery:

jQuery(document).ready(function(){
    jQuery('#admin-page-wrapper ul').sortable({cursor: 'move'});

});

Here is my order of jquery which are enqued

 wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');

And here is my plugin code

<div id="admin-page-wrapper">
        <h2>Published Pages</h2>
        <?php 
            $pages = new WP_Query(array('post_type'=>'page','post_status'=>'publish','posts_per_page'=>'-1','order'=>'ASC'));
        ?>
            <ul id="dashboard-page">
          <?php  if($pages -> have_posts()){
                while($pages -> have_posts()){
                    $pages->the_post(); ?>
                    <li class="dashboard-item"><?php echo the_title(); ?></li>
                <?php }
            } ?>
            </ul>
</div>

Add 3rd script & add it as last one:

wp_enqueue_script( 'jquery-ui-sortable');

You can find a list of all WordPress built in scripts at this page:

https://codex.wordpress.org/Function_Reference/wp_enqueue_script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM