Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Page & Category Menu Bars »

Help with Categories Menu, I want to add a Post counter in it, same as in the widget


  #1  
Old Jul 30, 2010, 12:47 AM
manuhoz
 
15 posts · Jul 2010
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
  #2  
Old Jul 30, 2010, 04:06 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Jul 30, 2010, 09:00 AM
manuhoz
 
15 posts · Jul 2010
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
  #4  
Old Jul 30, 2010, 09:46 AM
manuhoz
 
15 posts · Jul 2010
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
  #5  
Old Aug 1, 2010, 02:39 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #6  
Old Aug 29, 2010, 05:05 PM
manuhoz
 
15 posts · Jul 2010
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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] add a little space between each post in Recent Posts widget cway Sidebars & Widgets 2 Jul 23, 2010 02:19 PM
Error when selecting 'add new widget area' or any menu item below this gaidin Sidebars & Widgets 2 May 22, 2010 01:27 PM
child categories of menu bar are underneath first post's swf for mac users... voodoo Page & Category Menu Bars 0 Feb 19, 2010 08:19 AM
Add categories in page menu bar dredfyl Page & Category Menu Bars 1 Jan 20, 2010 03:11 AM
Post categories listed in Page menu lira Page & Category Menu Bars 1 Dec 11, 2009 03:10 AM


All times are GMT -6. The time now is 11:11 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.