Pass Category ID from one page to the next
-
Hello!
On a custom-post-type overview page (category.php) I can select between different categories so posts in a specific category i shown.
When entering a post page (content-single.php) I would like also to display a list of posts from the same catagory that the user just selected on the previous page. Like related posts.
I thought one way could be with a global variable, but I′m stuck. Can′t figure out how to get the Cat_ID passed over. This is what I got. Any help will be much appreciated.
In the category.php I have:
$catname = single_cat_title( '', false ); global $category_id; $category_id = get_cat_ID($catname);
In the content-single.php is this. But no number is printed.
<?php global $category_id; echo $category_id; ?>
- The topic ‘Pass Category ID from one page to the next’ is closed to new replies.