Use the following code, replacing the number after “child_of=” to the id of the parent page.
<?php
$count = 0;
$pages = get_pages('child_of=681&depth=1');
foreach($pages as $page) {
$count++;
}
echo $count;
?>
Reference: get_pages
Related Posts:
- Loop on a wordpress Page instead of content coming from the WP text editor
- Getting only direct child pages in WordPress with get_pages
- Check if a menu is empty?
- How to loop over custom fields in a page template?
- Exclude pages with certain template from wp_list_pages
- Switching between custom templates in a post type of the admin menu
- Custom excerpt function re-factoring
- Custom Template 404 for specific custom post type
- how could I load a different template part by page
- How to hide all child pages with post_query?
- Change title only in dynamic page
- Does wordpress templates always in files or in database?
- Adding wrapper elements in the_date() like in the_title()?
- WordPress template page name displayed on screen
- Posts are not looping through correctly
- Prevent header and footer from loading on specific pages with template or plugin
- Display articles with a different template in the home page | Solved |
- Check if current post in loop is last on current page
- Loop returns more items than exist?
- Problems With Query and/or Template Part and/or PHP
- How can I put a custom field as the link of a button shortcode?
- why is this content-template not showing any of my blog-entries?
- Tables not showing divs and loop/php items
- How to get URL of current page displayed?
- Ways to have multiple front-page.php templates that can be swapped out?
- What exactly does “Posts page” do in WordPress?
- WordPress Template Engine?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- Display only text to WordPress loop without loosing the text formatting
- Blank on static home page?
- Custom post type loops with different page templates
- Adjust the results quantity for Search Results page pagination
- WordPress loop specific thumbnail size
- get understrap pagination to work with custom query
- Is it possible to use the featured image of a page as a css background without inlining?
- Woocommerce – How to get products which have a sale between 20% to 40%? [closed]
- Displaying Only Certain Tags in Loop
- Password protecting content in custom template
- How to exclude specific category from the get_the_category(); array
- How can i display post loop in table format?
- How to select WooCommerce products by post_meta and order them
- An unwanted inline style is added to my body tag
- How to Display a Single Post Excerpt
- Cannot display or echo alt text on featured image
- Using Advanced Custom Fields to create a per page slider
- WordPress Search Results for Multiple Post Types
- Using loop pagination on single.php
- How to display pictures from database?
- how to refresh div on template part?
- Display category name only once inside loop
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Use WordPress function in php file
- Add filter multiple times using only one master function
- wp_query get the 2nd post
- How to add div blocks after certain set of post
- How do I remove a category from a wordpress loop>
- Removing WordPress Footer -without access to PHP code?
- Create page template via functions.php?
- Short code template + ajax
- how to display this functions?
- is_page_template showing partial results
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Adding regular php file to site
- Post repeated when opening in overlay, how do I solve this? [closed]
- Echo array value
- pass html code to worpdress
- Strip from or something better?
- How to break up php code to avoid echo
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- Getting a WordPress tag to print inside of a traditional php echo
- Products listing check if meta checkbox is checked
- Contain multiple page templates in one PHP custom template file in WordPress?
- Display metabox galleries on specific page template in admin editor
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Run do_shortcode on php template using JS function
- How to hardcode header and footer in WP?
- Get title of page containing post grid within the posts
- cURL needing to loop through all “next_page”
- Display page content in different sections – based on page break block?
- How to add a full working piece of website already coded, to a large scale Website design project?
- If is_page elseif is_page not working like I want it to
- How can I get my pagination loop to display the correct number of total pages?
- How do if all posts has this category ID then do this
- missing admin bar and widget in a template
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- View tag description on page
- My own theme’s custom widget areas are not working
- Insert div after every three posts in home.php [duplicate]
- Display product attributes for current product
- Create Customization Controls from Array
- How to call a certain object/menubar in a PHP file
- ACF loop and php formatting
- How to have post count after each listed category
- Transient Loop Not working as expected
- why is markup routinely placed in functions in wordpress?
- Conditional in foreach loop is outputting content twice
- Alternative loop syntax error [closed]
- is there away to hide php code in wordpress not to show in PAGES
- redirect user from login page if is logged