Hopefully this helps someone else
Dont forget to change “your_post_parent_id_here” with the parent id of your choosing.
global $wpdb;
$wpdb->query( 'SELECT @i:=-1' );
$result = $wpdb->query(
"
UPDATE wp_posts SET menu_order = ( @i:= @i+1 ) WHERE post_parent="your_post_parent_id_here" ORDER BY post_title;
"
);
Related Posts:
- Why isn’t is_page working when I put it in the functions.php file?
- Get the ID of the page a menu item links to?
- Disable visual editor on one specific page
- How can I programmatically create “child” pages on theme activation?
- How to display error messages using WP_Error class?
- Slugs as breadcrumbs for Pages
- Check if has any sidebar active on current page
- Remove Page Title from Static Frontpage
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Pages should have priority when using add_rewrite_rule
- Enqueuing Script in functions.php vs on the page
- Programmatically set page template based on page ID
- Delete pages and Create default pages for all new network sites
- how to change link of some wordpress pages
- Make menu structure match page heirarchy on page parent change
- Change the slug of a particular page every x hours
- wp_insert_posts keeps adding multiple pages
- How to include local menu based on page id?
- is_account_page() change to page slug
- Don’t delete a page if it holds users
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- Display post shortcode content in the sidebar?
- Why is my page feed returning empty content?
- Function only on a specific page
- Functions For Calling Specific Elements
- Get page id or status by private pages?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- Enqueue script on every page except one
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How do I register a new settings page? [closed]
- Only echo Page Content (not page title & page content together)
- get content from page through AJAX
- How to assign php file(template) to several pages with same prefix page name/slug
- Remove the delete link from pages without a plugin
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- Define an extra field for all pages (with no plugin?)
- Custom field not updating via functions upon publishing
- Using array page name together with page id to deregister script
- How to add a class name to the ancestor of a post?
- How to add an excerpt and read more link to a page?
- My website is generating weired url parameters of paginated pages
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Is it ok to use a function to output the text domain name in a wordpress theme
- Issue with wp_get_attachment_image() and SVG file type
- deregister scripts on certain page
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Using get_terms for custom taxonomy in functions.php
- Hide some items from Screen options in dashboard for products
- Editing or filtering the output of the Genesis navigation
- edit role display name and label name without plugins
- is_plugin_active() not properly returning true
- Display gallery on top before content
- List of Body Classes Generated by body_class()
- post to subcategory and parent in wp_insert_post
- Replace menu links with # and add name to its li
- Variable if post is sticky in functions.php
- Change template on the fly based on post parent selection
- Create a new query in function.php to filter blog posts
- Use third party Library in wordpress
- Remove the product category module block from the Woocommerce product page
- How to get correct URLs in network wide menu (Multisite)?
- Remove category from url
- ‘Attempt to modify property of non-object’ warning
- Conditional functions.php on page template
- Optimizing a WordPress site
- different style sheet for just one page template
- Problem with comments_number()
- Functions when woocommerce isn’t installed
- How to target post and pages and not all post types in admin?
- Dequeue script to prevent javascript event conflict on wordpress child theme
- Passing global variable from header.php to functions.php
- How is $current_page passed in woocommerce_account_orders function?
- Upgraded server now class My_Walker_Nav_Menu extends Walker_Nav_Menu not working
- How to include any template using Shortcode fuction?
- display a div on ervery site but not frontpage?
- How do I pull avatar from post using BuddyPress? [closed]
- Replace header image on all other pages but home – URL issue
- Child theme functions.php
- How to echo Widget Title in Custom Frontend-Template Box
- Getting images from media library and get_the_date() not working
- WordPress show bad the php hour and date
- Using add_image_size in functions.php to get original uploaded file
- show all the posts thumbnails
- the_excerpt function not showing image
- How do I change where “You must be logged in to comment” directs users?
- Login cookies blocked after customizing hashing method
- Enable CORS Request for hostname using IP address
- Change default color scheme in twentyfifteen child theme?
- Restrict access if logged out except for homepage
- Add meta data in head from theme
- DISABLE wordpress upgrade page
- How to echo the translated custom field?
- How to list out all values from the get_body_class array
- Moving CDN jQuery to footer does not work?
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- Hiding Google Analytics code based on theme options
- How do I make my child theme’s CSS update when I save it?
- How to automatically load Google Fonts on pages only as they’re used?