I am creating a page which shows all post categories and image associated with the categories. Each category has a textbox for the user to paste an image's URL and the page will then display the proper image for each category along with its name.

The issue I'm having is in the code below:

    $cats = get_categories();
    $category_images = get_option( 'category_images' );

    foreach ((array)$cats as $cat) {
        $catdesc = $cat->category_description;
        $catnumber = $cat->cat_ID;

    echo '<div><a href="'. get_category_link($cat).'" title="'. strip_tags($catdesc) .'">'. $cat->cat_name . '</a></div><a href="' . get_category_link($cat) . '" title="'. strip_tags($catdesc) .'"><img src="' . $category_images[1] . '" alt="' . $cat->cat_name . '" /></a>';

Now $category_images[#] will grab the URL from the database of whatever specified category ID so in this case its "1". Is there anyway to instead of loading "1" that it loads the ID of the category it is loading?


  • Can anyone at least give me a yes or no to if this is possible? – BorderlineVis May 31 '16 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.