get_cat_ID and a variable
Please help me see what I’m doing wrong.
I was getting a list of posts to display where the category is the same as the title of the page they are being displayed on. However I now need to display posts from this category but only when they are in another category.
This means getting the ID of the category that shares the name with the page. So I’ve been doing this:
<?php $cat_title = wp_title('', false); $category_id = get_cat_ID($cat_title); echo $cat_title; echo $category_id; ?>
Now the echo $cat_title variable prints out the title of the page(also the category name/slug) perfectly. But the echo $category_ID always prints 0; a fail.
I have played with every orientation of the syntax but nothing seems to work.
I have seen other example passing a variable to get_cat_ID that people said worked fine….. What am I missing?
- The topic ‘get_cat_ID and a variable’ is closed to new replies.