retrieve custom post image through widget

Your calls to get_the_post_thumbnail do work, the problem is how what you’re doing with the result: <input type=”checkbox” name=”<?php echo $this->get_field_name( ‘photo’ ); ?>” value=”<?php echo esc_html(get_the_post_thumbnail( $post->ID, ‘thumbnail’ ) ) ?>” <?php checked( $instance[‘photo’], get_the_post_thumbnail( $post->ID, ‘thumbnail’ ) ); ?> > You can’t put image HTML tags inside of another tags attributes, that’s not … Read more

Troubles with code for upload a image

well i look and i look and finally i found this work that work for me. $upload = wp_upload_bits( $_FILES[‘image’][‘name’], null, file_get_contents( $_FILES[‘image’][‘tmp_name’] ) ); $wp_filetype = wp_check_filetype( basename( $upload[‘file’] ), null ); $wp_upload_dir = wp_upload_dir(); $attachment = array( ‘guid’ => $wp_upload_dir[‘baseurl’] . _wp_relative_upload_path( $upload[‘file’] ), ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, basename( $upload[‘file’] … Read more

Custom field picture instead of post thumbnail on category page

I reckon you use the image URL in your custom field. $metro_creativex_posttitle = get_the_title(); // Not used in this snippet /* // you don’t need this block $metro_creativex_feat_image = wp_get_attachment_image_src( $post->ID, get_field(‘sd_single_img’), ‘single-post-thumbnail’ ); */ // you’ll need `$post_id` for each song $img_src = get_field(‘sd_single_img’, $post_id); if( !empty( $img_src ) ) { // echo if … Read more

Remove Featured Image based on Date

@Romulus Since you are using WordPress, I would highly suggest using WordPress’ functionality as much as you can. I would recommend using PHP and creating your own plugin or some kind of script that you can run. There are lots of tutorials out there that will give you the bare-bones implementation for creating a simple … Read more