Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

linux4me2 on "WordPress - Setting a default 'featured image' for each Catergory"

$
0
0

Try this instead:

function default_category_featured_image() {
  global $post;
  $category = get_the_category($post->ID);
  switch ($category[0]->term_id) {
    case '2':
      set_post_thumbnail($post->ID, '112');
    break;
    case '3':
      set_post_thumbnail($post->ID, '115');
    break;
    case '4':
      set_post_thumbnail($post->ID, '113');
    break;
    case '8':
      set_post_thumbnail($post->ID, '114');
    break;
    default:
      set_post_thumbnail($post->ID, '0');
  }
}
add_action('the_post', 'default_category_featured_image');

Viewing all articles
Browse latest Browse all 26892

Trending Articles