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
- WordPress post-template null warnings
- Get and insert order email address to the PHP template inside HTML text
- Custom search results page not working with empty search
- Can’t access variable outside for loop
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- How to show single category archive
- Iterate through posts based on array of categories
- code is skipping a div
- Issues getting PHP to display in category pages
- get author_name from queried post
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Increase offset while looping
- How to display pictures from database?
- Blog posts repeat
- How to add condition in wordpress loop? [closed]
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- Dynamic content in template
- Populate editor with some content of a page with a page template
- How to get the value of input hidden html from text editor to custom page template?
- Secondary navigation menu on one page
- Enable custom logo upload if logo is not in header
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Display category name only once inside loop
- Can’t find infinite loop cause
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- Load wordpress content in other domain
- 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
- How can I edit the content in index.php? [duplicate]
- Checkbox doesn’t stay checked, conten
- Automatic Shortcode Creation with Custom Fields [closed]
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Show a different code on front page to other pages
- post thumbnail, conditions, else wont work
- Widgets in the loop if active
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- List posts that don’t have a specific tag?
- Inject class in body when particular page template is used
- Changing the_posts_navigation() html output
- Can we count the WordPress Loop
- PHP include is only working in certain places in my custom WP theme
- Use WordPress function in php file
- Get post id within comments loop
- How to get all author posts outside of author templates
- Syntax error when I try to insert my loop into an unordered list? [closed]
- WP_Query fails despite having 1 post
- Add filter multiple times using only one master function
- Create a Blog Template Page
- Showing latest post without 301 redirect
- Show meta box only for default page template
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Add content after the first post in WP Loop
- wp_query get the 2nd post
- Loop stopped working
- How to get post ID in a Page?
- Custom Pagination is Broken
- Display an image if odd number of posts in grid
- How to loop through all the attached images in a post, and get their url one by one
- Display custom field on 404 page outside loop
- single.php with different look by category
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- PHP Warning: strip_tags() expects parameter 1 to be string?
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Store post content in a php variable and output them using for loop
- How to add div blocks after certain set of post
- Echo a shortcode div after every 3 posts
- How to avoid duplicates when creating recent network posts
- How to overwrite orderby with add_query_var
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Why in my theme I can’t see all the statics content under the posts?