Retrieve category_id’s in the loop

Problem:
User is looking for the right function to retrieve all category_id’s of a specific post within the loop.
He wants to store the id’s in a variable or an array.

Following is the solution of above stated problem.
Solution: We have finally found the function to solve the problem.

foreach((get_the_category()) as $cat)
{
echo $cat->cat_ID;
}

Conclusion:
Its solution is very simple. You have to just use above code in your website and enjoy the results.

Leave a Reply

Your email address will not be published. Required fields are marked *