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

Can’t seem to attach uploaded image to post and set it as thumbnail

You have a variable scope problem. $post_id = wp_insert_post($post_information); function upload_user_file( $file = array() ) { require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $file_return = wp_handle_upload( $file, array(‘test_form’ => false ) ); // … You set $post_id outside of your upload_user_file() function but that means that it is unavailable inside the function where you need it for … 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