scdwb
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: wp_dropdown_categories problem – Show roots URLSimply changing the form method from post to get solved this problem. As now when I use the form the url is domainname.com/category/ and therefore page navi works fine.
The only problem now is that because I am using an image for the form submit, and using method get, the url has /?x=N&y=N parameters. Still works but I am going to search and find away to remove these as they aren’t useful to me.
Forum: Fixing WordPress
In reply to: Display number of authors in a categoryWahoo! Thank you it is finally working. This is my finished code:
$catauthors = array(); $allposts=get_posts("cat=$city&showposts=-1"); if ($allposts) { foreach($allposts as $authorpost) { $catauthors[$authorpost->post_author]=1; } echo count($catauthors); }
Thanks Michael, I have learned a lot from this ??
Forum: Fixing WordPress
In reply to: Display number of authors in a categoryIm getting somewhere now but it has some problem. I have this code:
$catauthors = array(); $allposts=get_posts("cat=$city&showposts=-1"); if ($allposts) { foreach($allposts as $authorpost) { $catauthors[$authorpost->post_author]=1; echo count($catauthors); }}
But if there is 1 instance of 4 different authors it echoes 1234.
If there are 2 instances of 4 different authors it echoes 11223344.
I need it to just echo the number of different authors in the categories. So if 1 author posted 100 posts and the other 3 just posted 1 in this category it would just display 4.
This must be possible? Thank you!
Forum: Fixing WordPress
In reply to: Display number of authors in a categoryThis is getting there. It listed the authors details in the $citycat category and echos out the details of the authors. But all I need it to do is echo out the number of authors from the &citycat category?
Im a bit lost of how to make this work using the code above.
Thanks in advance!
Forum: Fixing WordPress
In reply to: Display number of authors in a categoryIts hard for a beginner to know how to use the arrays with the wordpress functions. I am familiar with arrays but how do I store the lists of authors in an array?
Is the foreach statement in my code correct? How do I store the list of authors encountered in an array?
Please help
Forum: Fixing WordPress
In reply to: Display number of authors in a categoryHi Michael, thanks again. I don’t know if you remember but this is going to be another method to solve my other problem we had no luck with before.
Ok, hmm im new to php. So can you help me out? Based on what you say im thinking something like:
query_posts("cat=$city&showposts=-1"); $authors = wp_list_authors(); foreach($authors as $author) { $number= $author->count; } } echo 'Number of authors is '.$number;
This obviously doesn’t work but im trying ??
Forum: Fixing WordPress
In reply to: Interesting category counting question.Thanks for your help apljdi.
I have used the code with the ID and have:
$sections = get_categories(array( 'parent' => 50)); echo count($sections);
This displays the total number of subcategories of ID 50, which is the letting agent category and there are 20.
What I need to do is somehow use this code to display the number of subcategories of ID 50 being used by the posts in my chosen city category.
So in php could we say something like:
1. Query posts from “city name” category
2. Then displays similar code to above to display the amount of letting agents active in this city.Thanks, this is getting so close.
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?OK, thanks for your help. Ill start another thread with a clearer explanation.
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Nope, its still displaying 265. I am a beginner in PHP but as I read the code all it is calling is the sub categories in “child_of=50” and just adding up all the posts in these sub categories?
What I need it to do is to just query all the posts in the $city category ($city variable is the ID) and count how many of the “child_of=50” categories are being used in these posts.
So for example, if 10 posts are in the $city category and 5 of these are in category 1 of “child_of=50” and the other 5 are in category 2 of “child_of=50” then the number that would be displayed is 2.
It must be possible but im really struggling to find out how to do this.
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?I have just removed the + from this bit of your code
$post_count+=
I can’t find any reference to += anywhere. Was this a type?
Anyway by removing this the result is always 3 for som reason?
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Thanks for your quick reply. At the moment this code is just displaying the total of posts in my site, 265.
So if I am right, the code is adding up all the mosts in all the category in child of id 50?
I need it to add up all the child categories being used in the category id 50, but only for the posts in my other chosen category (defined as variable $city).
IS this possible?
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Thanks again Michael,
I’m getting closer, this code echos the total number of child categories
$categories= get_categories('child_of=50'); $result = count($categories);
I’m trying to echo the number of child categories of category id 50, but which are being used in the posts in the $city variable category.
Something like this, but this code doesn’t work (I have the cat id in the $city variable:
query_posts("cat=$city&showposts=-1"); $categories= get_categories('child_of=50'); $result = count($categories);
Can you help me out? Thanks.
Steve
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Thanks Michael,
Im not sure how to make this work though for the posts being queried
query_posts("cat=$city&showposts=-1"); $categories= get_categories('child_of=50');
How would I count the number of child categories being used within these posts?
Thanks!
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Can anyone point me in the right direction with this?
Thanks!
Forum: Fixing WordPress
In reply to: Number of categories in X Category these posts belong to?Can anyone help me out with this? I’ll try and explain it better.
I need to take all the posts in a selected city category (I have this ready in a variable) and find out the number of subcategories being used in the posts from the Company category.
For example I may have 10 posts in the London Category. 5 of these posts are also in the “Company1” category and the other 5 are in the “Company2” category.
So I need to find a way to calculate that there are 2 companies being used in these 10 posts.