Boys and girls. i can not find the solution of this:
I am writing a function in functions.php to show all post titles depending on opened post.
F.e If the post belongs to category Books and there is another posts within this category – show those post titles.
The trick bhind this is – the function is outside the loop. I am trying to get the active category Id, but it always returns last created category Id
$categories = get_the_category();
$category = $categories;
$cat_id = $category->cat_ID;
Do you know, how to return the category id outside the loop when reading a post?
- The topic ‘Get post category outside the loop’ is closed to new replies.