Count Number of Parent Pages Only
-
Hi, folks.
What I want to do:
I’ve recently built a website with a horizontal pulldown navigation. Basically my goal is to make the parent items a liquid width so that regardless of how many parent pages are present, the nav items will fill the horizontal bar (make sense so far?).What I need in order to accomplish this:
What I need is to be able to count the number of parent pages only so that I can use that number to determine how wide in percentage to make each parent navigation item. I’ve accomplished this on another system (CMS Made Simple) but have yet to do so via WordPress.I found out how to count the total number of pages which is a step in the right direction. Now If I can exclude child pages from this count, I would be set. This is what I’ve got thus far:
$num_pages = wp_count_posts('page'); $num_pages = $num_pages->publish; echo $num_pages;
If anyone has a much better way of accomplishing this, I’m open to that as well. Thanks in advance!
- The topic ‘Count Number of Parent Pages Only’ is closed to new replies.