• Resolved viettrong

    (@viettrong)


    When I customized template in category.php if there is no featured image for a post,use the fall back image defined for the post category.I don’t know how to get featured image category url.Here is my code.Please help me!

    $category = get_category( get_query_var( ‘cat’ ) );

    $cat_id = $category->cat_ID;

    $image_id = get_term_meta ( $cat_id, ‘category-image-id’, true );

    echo wp_get_attachment_image ( $image_id, ‘large’ );

Viewing 1 replies (of 1 total)
  • Plugin Author CK MacLeod

    (@ck-macleod)

    I don’t know why you expect category-image-id to exist in the database as term meta. Anyway, it seems like that’s what you’re expecting. There are other problems with your code, but that’s the main one. If you look at the plugin code, you might be able to figure out how image ids are associated with categories, but you might have better luck using the template tags that are provided with the plugin. See the settings page for instructions.

Viewing 1 replies (of 1 total)

The topic ‘Can not get fallback image url’ is closed to new replies.