WordPress.org

Support

Support » How-To and Troubleshooting » wp_get_post_categories()

wp_get_post_categories()

  • $posts = get_posts();
    if ($posts)
    {
    foreach ($posts as $post)
    {
    $post_categories = wp_get_post_categories($post->ID);
    foreach ($post_categories as $cat)
    {

    Now, what is $cat? Codex says wp_get_post_categories() retrieves “the list of categories for a post.” So first I thought it was an object, but it’s an integer. Could it be the Category ID? No. It’s always 1, even if there are posts in different categories. What is it, and how do you use it?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_get_post_categories()’ is closed to new replies.