WordPress.org

Forums

can't get category_id (2 posts)

  1. bigdyce504
    Member
    Posted 5 years ago #

    Can anyone tell what I'm doing wrong here. The 'category_id' won't show.

    <?php
    $categories = get_categories($args);
    foreach ($categories as $cat) {
    echo 'category_id.'"><span>'.$cat->cat_name.'</span>   ';
    }
    ?>

    *Literally pulling my hair out*

  2. alchymyth
    Forum Moderator
    Posted 5 years ago #

    reread http://codex.wordpress.org/Function_Reference/get_categories

    as your code got corrupted ( you entered it without backticks or without using the code button of this editor) i don't know what you wanted to achieve:

    the category id would be: $cat->term_id

    i assume you have an array with the arguments build before your code snippet; what are your $args before this code?

Topic Closed

This topic has been closed to new replies.

About this Topic