Search the Community
Showing results for tags 'category posts'.
-
Reference: PW 3.0.62 and uikit3 based site using the Reglar-Master profile. I'm trying to add a count of the number of category posts to display beside each of the category titles listed in the sidebar on the blog page. The following code displays the total number posts on each category page: <span class='uk-text-muted'>Total <?php echo page()->title; ?> posts: <?php echo count(pages()->get('/blog/')->children("categories=$page")); ?></span> The following default code displays the heading and a list of the categories: <?php $categories = pages()->get('/categories/'); echo ukNav($categories->children, [ 'header' => $categories->title ]); ?> but I want to add the respective number of posts on the same line as each category title listed. When I try replacing the default code with the following: <?php $categories = pages()->get('/categories/'); $catposts = count($categories->children("categories=$page")); echo ukNav($categories->children . ' ' . $catposts, [ 'header' => $categories->title ]); ?> I get the following error: which refers to the following code in the _uikit.php file: $page = $items->wire('page'); // current page and when I try: <?php $categories = pages()->get('/categories/'); $catposts = count($categories->children("categories=$page")); echo ukNav($categories->title); foreach ($categories as $category) { echo $category->children . ' ' . $catposts; } ?> or: <?php $categories = pages()->get('/categories/'); $catposts = count(pages()->get('/blog/')->children("categories=$page")); echo ukNav($categories->title); foreach ($categories as $category) { echo $category->children . ' ' . $catposts; } ?> I get the same error. If I change to I get the following error messages: Any advice on where I am going wrong would be very much appreciated.