Hi
I am trying to do a page which lists all the available categories PLUS the list of posts for the current category being viewed.
I can use $cat once and it works but as soon as I click on one of the posts listed for the current category, the list of posts disappears due to the $cat not being remembered or being populated.
Is there any way around?
This will be difficult, since a post can be assigned to any number of categories. I'm not sure exactly how you're using $cat, but you could try and "fake" the variable on a single post page like so:
<?php global $post;
$categories = get_the_category();
foreach($categories as $category) {
$cat = $category->cat_ID;
} ?>
For a post in multiple categories this assigns the last one to $cat.
Hi
Please see http://www.tricksbox.com/wordpress
Here I am listing the two available categories and then displaying only 1 post.
I want to be able to get the category id of the viewed post and display its articles.
It goes wrong when clickin the listed posts, sorry hard to explain.