Listing Number Per Category?
-
Is there a way to list the number of posts next to the category listings?
-
Hi,
I am using this code and it is working.<?php wp_list_categories(‘show_count=1&title_li=<h2>Categories</h2>’); ?>
Now, I can see the number of the posts in brackets.
I hope it helped you.Peter
Where do you put this at?
into the sidebar.php
You should find out your way…
Here is my sidebar.php (but in this case I do not use widgets…)<div id=”right”>
<div id=”sidebar”>
-
<?php /* Widgetized sidebar, if you have the plugin installed. */
- <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>
-
<?php /* If this is a 404 page */ if (is_404()) { ?>
<?php /* If this is a category archive */ } elseif (is_category()) { ?>
<p>You are currently browsing the archives for the <?php single_cat_title(”); ?> category.</p><?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
<p>You are currently browsing the /”><?php echo bloginfo(‘name’); ?> weblog archives
for the day <?php the_time(‘l, F jS, Y’); ?>.</p><?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<p>You are currently browsing the /”><?php echo bloginfo(‘name’); ?> weblog archives
for <?php the_time(‘F, Y’); ?>.</p><?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<p>You are currently browsing the /”><?php echo bloginfo(‘name’); ?> weblog archives
for the year <?php the_time(‘Y’); ?>.</p><?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
<p>You have searched the /”><?php echo bloginfo(‘name’); ?> weblog archives
for ‘<?php the_search_query(); ?>’. If you are unable to find anything in these search results, you can try one of these links.</p><?php /* If this is a monthly archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
<p>You are currently browsing the /”><?php echo bloginfo(‘name’); ?> weblog archives.</p><?php } ?>
- <h2>Archives</h2>
if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?><?php if ( is_404() || is_category() || is_day() || is_month() ||
is_year() || is_search() || is_paged() ) {
?><?php }?>
<?php wp_list_pages(‘title_li=<h2>Pages</h2>’ ); ?>
-
<?php wp_get_archives(‘type=monthly’); ?>
<?php wp_list_categories(‘show_count=1&title_li=<h2>Categories</h2>’); ?>
<?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
<?php wp_list_bookmarks(); ?>- <h2>Meta</h2>
-
<?php wp_register(); ?>
- <?php wp_loginout(); ?>
- Valid XHTML
- XFN
- WordPress
- Bob
<?php wp_meta(); ?>
<?php } ?>
<?php endif; ?>
</div></div>
Peter
I have a L-sidebar.php file, would I put it there? SOrry, i’m new to this all. I have an understanding of how phpbb files work, but this is kinda confusing me.
L means left?
If this is the case doesn’t matter. You can copy into that.
I put the mentioned code in the place I wanted to see (after the Archives as you can see).
Try this way. (You can undo anytime just keep you original file in a sav place and can reupload if it doesn’t work.)
Or show me the L-sidebar.php and I try to solve your problem…
??
Just a question: do you use any widget on your sidebar?
PeterThe new theme i’m using has three columns, yet I don’t see a left_sidebar file. There’s a right sidebar file and a regular sidebar.php file?
Do you want me to post both of them?
And yes, I use widgets.
Oooops, one more question:
Which theme do you use?
PSorry… after the “What about this” there was a link about the admin panel. I try it again:
spuhulinux.blog.hu/media/image/mix/wordpress/widgets.pnghttps://spuhulinux.blog.hu/media/image/mix/wordpress/widgets.png
As you can see I am in hurry… ??
SPaeteur, thank you very much for giving the tips. I have mine working without cracking my head. However I have one small issue that I cannot seem to find the solution. the number appear below the category. I intend to place the number next to the category. is that possible ?
thanks in advance.
Bujuk
Good morning Bujuk,
Sorry, I was away a bit.
The line(s) should be like this:<li><h2>Categories</h2> <ul> <?php wp_list_categories("show_count=1&title_li="); ?> </ul> </li>
and this works for me. The numbers are next to the category names.
So, maybe you should copy this part of your code, just to have a look at it.
Peter
- The topic ‘Listing Number Per Category?’ is closed to new replies.