WordPress.org

Ready to get started?Download WordPress

Forums

Echo Child Page & Grandchild Page Count (1 post)

  1. CKemp
    Member
    Posted 4 months ago #

    Hey guys, thanks for considering my issue.

    What I'm trying to do:

    Show count for Child Pages and Grandchild Pages seperately.

    So on a parent page it would something like this:

    Currently 11 child pages and 34 Grandchild pages.

    My code currently:

    <?php
    $children = get_pages( array(
    'child_of' => $post->ID,
    
    ) );
    echo count($children);?>

    It displays a count of total children indiscriminately. WordPress docs tell me that it can be modified using "'parent' =>" but I haven't been able to make it work.

    Any suggestions?

    Thanks for your consideration.

Reply

You must log in to post.

About this Topic