How to not show post_thumbnail from specific category for not logged users

You can hook a filter to the post_thumbnail_html and check if its a post in that category and if the user is not logged in ex: add_filter( ‘post_thumbnail_html’, ‘my_post_image_html_wpa92119’, 10, 3 ); function my_post_image_html_wpa92119( $html, $post_id, $post_image_id ) { $category_to_exclude = “CHANGE_WITH_CATEGORY ID”; $logIn_Img_path = “CHANGE THIS WITH PATH/TO/NON-LOGGED/USERS/IMAGE”; //check if the post have that … Read more

Exclude featured image from attachment loop

Try to use that set of arguments : $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘numberposts’ => -1, ‘post_parent’ => $post->ID, ‘orderby’ => ‘menu_order’, ‘order’ => ‘asc’, ‘post__not_in’ => array( $thumb_id ) ); I’m using it for one of my site and it’s working fine. So you shouldn’t have to use : if … Read more

MultiPostThumbnails for Custom Post Type

All I apologize the code above was not completely working. I did research and found out how to condense the code for Multipostthumbnails so you can easily include the added thumbs for page, post and/or custom post types. Please let me know if you have a cleaner method. add_theme_support( ‘post-thumbnails’ ); require_once(‘lib/multiple-post-thumbnails/multi-post-thumbnails.php’); /* Must be … Read more

How to offset thumbnails to the center?

I tried and use successfully this code which allow to define image size using specific cropping position for this image size : bt_add_image_size( ‘product-screenshot’, 300, 300, array( ‘left’, ‘top’ ) ); It allow centering option so it looks like matching your purpose. I’ve added the code in a separate php file that I included into … Read more

Get ID of featured image using “get_post_thumbnail_id(the_ID())” – without printing to screen?

You should not use the_ID() in this case, since it will echo the ID, use instead get_the_ID() to return it. So please try this instead: $thumb_id = get_post_thumbnail_id( get_the_ID() ); to get the ID of a post thumbnail image. The general rule is that the_*() functions will echo the output, but get_*() functions will return … Read more

How to get cropped thumbnail source for custom post type

You should add your custom image size with this code: add_image_size( ‘my-test-image-size’, 148, 148, true ); Then in your template file you can get cropped image using wp_get_attachment_image_src like this: $attachment_id = …; // i.e. get_post_thumbnail_id() $image_info = wp_get_attachment_image_src($attachment_id, ‘my-test-image-size’); echo ‘<img src=”‘. $image_info[0] .'” … />’; // $image_info[0] contains url of cropped image To … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)