Help with Categories Menu, I want to add a Post counter in it, same as in the widget
Dear friends,
I'm sorry for my poor english, this is maybe the reason I couldn't find the answer to my question in the forum because using the wrong words. Maybe the issue is very simple, I would like to add, in the category menu, a counter of posts in each categorie, as you can have in the categories widget. How to proceed ? I hope I'm clear enough. Have a nice day Manu |
You will have to look for a plugin or code your own. There is nothing in the theme to do this.
The category menu, is created by calling the wordpress function 'wp_list_categories()' (see http://codex.wordpress.org/Template_...ist_categories for reference) to get the count, you would have change the code to add another SQL call to do a join and count the entries, then after you got the count, you would have to change the code that prepares the menu to account for the number. If you are a programmer and are comfortable with php, have at it. The code for the BFA popular Cat widget is in bfa_popular_in_cat.php, the menu code is bga_hor_cats.php. |
I did programming, not used to php, I try to write some code, I'm not gonna disturb you until I got some concrete lines :)
thanks Manu |
Dear Juggledad,
I Read your comment, and look into the code, but in both popular_in_cats and hor_cats I can't find where they call the function "wp_list_categories" anyway I found in popular in cat this : if ($bfa_pic_posts) { foreach ($bfa_pic_posts as $bfa_pic_post) { $bfa_pic_post_title = stripslashes($bfa_pic_post->post_title); $bfa_pic_comment_count = $bfa_pic_post->comment_count; $bfa_pic_permalink = get_permalink($bfa_pic_post->ID); $widget_mdv_most_commented_per_cat .= '<li><a href="' . $bfa_pic_permalink . '" title="' . $bfa_pic_post_title.'">' . $bfa_pic_post_title . ' (' . $bfa_pic_comment_count . ')</a></li>'; So probably this what create the counter in the categories widget, Do you think I can get (and how) the value of $bfa_pic_comment_count in hor_cats for adding the number after the name of each categories ? I think I'll have to call the variable here but I'm not sure of the syntax : function add_descr_cat_menu_links($matches) { global $bfa_ata; if ( strpos($matches[1],__('View all posts filed under')) !== FALSE ) { if ( $bfa_ata['default_cat_descr_text'] != '' ) { $default_cat_descr = str_replace("%category%", $matches[2], $bfa_ata['default_cat_descr_text']); return '>'.$matches[2].'<br /><span class="cat-descr">'.$default_cat_descr.'</span></a>'; } else { return '>'.$matches[2].'</a>'; } } else { return '>'.$matches[2].'<br /><span class="cat-descr">'.$matches[1].'</span></a>'; } } Thanks in advance Manu |
You will need to test what ever you try. I pointed out the code so you could see how atahualpa is doing it. Personally, I'd figure out how to build a plugin to do this if I really needed it.
|
Dear All,
So I made a little progress, when I add, in hor_cats show_count=1& like this : $list_cat_string = wp_list_categories('show_count=1&orderby=' . $sort_order . '&order=' . $order . '&title_li=&depth=' . $levels . '&exclude=' . trim(str_replace(" ", "", $exclude)) . '&echo='); it displays the number I want but under the category box, I don't know why, like you can see currently on my website : http://www.radiatorhymn.com The problem is, I have no control at all, on how to display it just after the category name. I don't understand which function call this list_cat_sting var, to display the informations it gets. I saw the hor_cats function is called by bfa_header_config, but after some test no results. I finally thought I should add a line in hor_cats like a pregreplace, to add the value at the end, but I really don't understand how it works. It's very boring to be so closed of the goal and can pass through it, it's probably very simple. I just want to solve this to publish my website. Thanks again Bests Emmanuel |
All times are GMT -6. The time now is 06:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.