WP count children of parent page
This function with shortcode let us to echo number of children of a parent page and with an icon.
function parent_page( $atts ) { $a = shortcode_atts( array( 'parent_id' => 'enter parent ID.', 'icon_name' => 'enter the icond name.', ), $atts ); $parent_id = "{$a['parent_id']}"; $icon_name = "{$a['icon_name']}"; if ( 'publish' === get_post_status( $parent_id )){ $image = get_template_directory().'/logos/'.$icon_name.'.png'; if(file_exists($image)){ $returnAll = "<a class='class_".$icon_name."' href='". get_page_link($parent_id). "'>" ; $returnAll .= get_the_title($parent_id); $returnAll .= "<img src='". get_template_directory_uri(). "/logos/".$icon_name.".png' >"; $returnAll .= " <span class='child_count'> ( ". count (get_pages( array('child_of' => $parent_id,)))." )</span>"; $returnAll .= "</a>"; }else{ $returnAll = "The icon not exist!"; } }else{ $returnAll = "The page not exist or not published!"; } return $returnAll; } add_shortcode( 'parent_page', 'parent_page' );
Call the function
<?php echo do_shortcode('[parent_page parent_id="15" icon_name="css"]');?>
50 Related pages
- About WordPress
- Child pages and Related pages display
- Display all posts title on any page, WordPress
- Display child pages of specific page anywhere, WordPress
- Display child pages of the current page, WordPress
- Display date the page created, WordPress
- Display related pages, WordPress
- dns-prefetch, remove, WordPress
- Featured image, WordPress
- Get all parent pages, WordPress
- Get current page ID, WordPress
- Get ID of most top page, WordPress
- Get parent title as URL link
- Hook to head with wp_head
- If has category, WordPress
- If has tag, WordPress
- If page is parent or child page, WordPress
- Implementing website design into the WordPress with minimum requirements
- Increase Maximum Upload File Size, WordPress
- List child pages of a specific page, WordPress
- List subpages even if on a subpage, WordPress
- Parent, Child and Grandchild page
- Show pages in the index page, WordPress
- Show related pages even on the subpage, WordPress
- WordPress Addmin Toolbar position
- WordPress count child pages
- WordPress Display child pages
- WordPress display single page by ID
- WordPress Error log redirect into specific file
- WordPress get template directory and uri
- WordPress post type icon
- WordPress Show only parent pages
- WordPress wp_enqueue_style
- WordPress, display all pages in website, Dropdown option select
- WordPress, display child and grandchild pages
- WordPress, Display parent pages only
- WordPress, Parent page has number of child pages
- WP Avenced Search
- WP Basic for WordPress Theme
- WP cache
- WP count children of parent page
- WP count page, post or custom post type
- WP count related pages
- WP Count taxonomy-name
- WP function with shortcode
- WP functions with shortcode
- WP generate theme online
- WP image exist
- WP plugin exists or active
- WP remove global styles from the head