Advertisement
Guest User

Featured Image by Custom Field and Category

a guest
Nov 9th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. function Function_img_cat($post_id){
  2.     global $post;
  3.     $theme_url = "http://www.redminka.com/wp-content/themes/redminkaepik";
  4.     $img_featured = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');          
  5.     if ( in_category('notas') ) {
  6.         $url_imagen = $theme_url.'/img/nota100.png';   
  7.     }else   if  ( in_category('enlaces') ) {
  8.         $enlaces_link = get_post_meta( $post->ID, 'url_link', true );
  9.         $enlaces_link_corregido = addhttp($enlaces_link);
  10.         $url_imagen = 'http://s.wordpress.com/mshots/v1/'.$enlaces_link.'?w=400';          
  11.     }else   if ( in_category('fotos') ) {
  12.         $url_imagen = $img_featured;               
  13.     }else   if ( in_category('videos') ) {
  14.         $video_embed =  get_post_meta($post->ID, 'url_video', true);
  15.         $url_imagen = 'http://img.youtube.com/vi/' .substr($video_embed, -11). '/0.jpg"';
  16.     }else   if ( in_category('documentos') ) {
  17.         $url_imagen = $theme_url.'/img/documento-descargar-100v2.png';
  18.     }else   if ( in_category('articulos') ) {
  19.         $url_imagen = $img_featured;
  20.     }else {}
  21.    
  22. update_post_meta($post->ID, 'img_categoria', $url_imagen);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement