| User | Post |
|
8:51 pm 18 Oct 2007
| proper
Guest
| | | |
|
| |
|
|
I am trying to mix categories, pages and posts to form up a portal-like site. Something that seemed out to be pretty impossible until I found the plugin.
The topmost sections of my site are represented by pages. So after installing the plugin I first assigned my top pages to the proper categories. Each of the top pages queries posts within the $cat category, which sould in theory return the posts assigned to the same category. And the sub-navigation uses wp_list_categories with child_of $cat to list subcategories within the category. And that’s where I noticed it just does not work - the $cat does not return anything. So instead of getting list of posts within the category I get a totally messed list of posts and the list of categories mixes up all categories of the same level and their subcategories. And it does not make difference whether I use $cat in the loop or not. So I started thinking - is it a bug in the plugin, or WordPress just can’t handle the idea of pages being assigned to categories and calling the $cat identifier. I thought the plugin might come up with a function that returns the ID of the current category instead of $cat, but as it seems it does not. So any ideas what the possible cause and fix might be? Thanks in advance.
|
|
|
|
|
Well I’ve read this through three times now and I am still confused. What is ‘$cat’ and where are you getting it from? Are you assigning this variable yourself? And what is missing from wp_list_categories()?
|
|
|
9:41 pm 18 Oct 2007
| proper
Guest
| | | |
|
| |
|
|
AFAIK $cat is the general WordPress variable that should return the category current post is placed under.
|
|
|
|
|
It’s a new one on me. I am not aware of any variable that does this. You may be right but of course and I’d welcome knowing more.
|
|
|
10:52 pm 18 Oct 2007
| Mr Papa
Moderator
| | Arizona, USA | |
|
| posts 1277 |
|
|
Andy, quick reference on $cat
http://wordpress.taragana.net/_variables/cat.html
in core wp, pages dont have categories, so I would imagine that variable is empty
|
|
|
10:54 pm 18 Oct 2007
| Mr Papa
Moderator
| | Arizona, USA | |
|
| posts 1277 |
|
|
argh, link isnt quite right… scroll down to $cat and select… then you will see all the settings and references… links take your right to the code…
|
|
|
|
|
Oh yes - $cat is a common variable used within the core. I was realy asking how it was exposed in a theme template. It’s only going to be available by using some function or other and that’s the important bit really.
But thanks for the list. That’s a useful resource! You certanly know you’re way around!
|
|
|
11:53 pm 18 Oct 2007
| Mr Papa
Moderator
| | Arizona, USA | |
|
| posts 1277 |
|
|
you should be able to get at $cat in a theme within the loop and just adding a global $cat statement before trying to use it… of course, I haven’t tried it… I have tried it with other "global" wp core variables…
|
|
|
|
|
As far as I can see $cat is only ever defined as a global in the function category_description() although I may well have missed it elsewhere. I rather think that;s a bit odd as well as it serves no purpose.
Of course creating a variable to hold the cat(s) is not difficult but as to the original question I would very much like to see how it is being done.
|
|
|
|
|
Double-checked. $Cat is NOT available as a filled variable in the loop rather as I suspected.
|
|
|
8:38 am 19 Oct 2007
| proper
Guest
| | | |
|
| |
|
|
I am trying to explain something utterfly difficult and complex (IMO) with my poor English, so I am sorry about that.
Basicaly the site structure looks like this:
Pages (assigned to categories)
- Posts (assigned to subcategories in the respective page category)
So my category structure looks like:
Resources
- Articles
- Press release
- News
and I have a page called Resources assigned to the resources category, and posts in Articles, Press release and News. I thought that would be the most convenient way for me to organize pages and posts.
As my PHP skills are close to zero, I am mostly trying to solve my problems just testing different ways. I am using WP as CMS platform for lots of projects and I have some skills already, but this project is something different.
In this case my loop in the page looks like this (pretty standard):
‘, ‘excerpt’, false, ”, false, 2, true); ?>
And my sidenav (that should display subcategories for the category where the page is assigned), looks like this:
foreach((get_the_category()) as $category)
echo ("
");
wp_list_categories("orderby=sort_column&hierarchical=0&depth=1&title_li=&child_of=" . $category->category_parent . "" );
echo ("
");
?>
… but it always returns just the first category subcategories.
Now when I think of it, you will probably be able to get the whole picture if I just send you the page template instead?
|
|
|
9:36 am 19 Oct 2007
| proper
Guest
| | | |
|
| |
|
|
Now, when I tested it a bit more, having a
<?php foreach((get_the_category()) as $cat) ?>
before the call seems to be fixing it.
|
|
|
|
|
OK…. So problem solved yes?
|
|