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>
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>
Share
Improve this question
edited Aug 23, 2015 at 7:37
Vipin
asked Aug 23, 2015 at 7:33
VipinVipin
1151 gold badge2 silver badges13 bronze badges
10
- 2 what error do you see in your console? – Deepak Ingole Commented Aug 23, 2015 at 7:37
- Do you get any errors? – AWA Commented Aug 23, 2015 at 7:37
- TypeError: jQuery(...).sortable is not a function jQuery('#admin-page-wrapper ul').sortable({cursor: 'move'}); – Vipin Commented Aug 23, 2015 at 7:41
- How is your jQuery and jQueryUI loaded into page? Original jQuery always needs to be loaded first and don't forget to also load jQueryUI. – AWA Commented Aug 23, 2015 at 7:43
- @AWA wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); – Vipin Commented Aug 23, 2015 at 7:44
1 Answer
Reset to default 9Add 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/Function_Reference/wp_enqueue_script