How to delete attachments associated with custom field type when post property changes? [closed]

You can use the save_post hook. add_action( ‘save_post’, ‘mytheme_my_post_just_updated’ ); function mytheme_my_post_just_updated($post_id){ $deal_type = get_field($post_id, ‘deal_type’); if($deal_type == ‘sold’){ $gallery = get_field($post_id, ‘gallery’);// This bit and the next few lines will depend on how you’ve set up the custom field. // Fast forward a few lines… foreach($images as $image){ // I’m assuming that $images is … Read more

Are WP images responsive by default?

It’s change automatically change image while image’s in responsive mode.We can add all images here so it’s cut automatically with screen size. add_action( ‘after_setup_theme’, ‘wpdocs_theme_setup’ ); function wpdocs_theme_setup() { add_image_size( ‘category-thumb’, 300 ); // 300 pixels wide (and unlimited height) add_image_size( ‘homepage-thumb’, 220, 180, true ); // (cropped) }

List all image sizes still getting disabled sizes

Have a look into the get_intermediate_image_sizes function code solves your question: /** * Gets the available intermediate image sizes. * * @since 3.0.0 * * @global array $_wp_additional_image_sizes * * @return array Returns a filtered array of image size strings. */ function get_intermediate_image_sizes() { global $_wp_additional_image_sizes; $image_sizes = array(‘thumbnail’, ‘medium’, ‘medium_large’, ‘large’); // Standard sizes … Read more

Displaying “alt” attribute text as captions?

A WordPress approach If you have all your Images in the media gallery, you are able to access their post object while embedding/including the images via tinyMCE or plain PHP. WordPress uses wp_prepare_attachment_for_js to get all information about their images for their blade templates. Maybe this will help you to get started. A maybe approach … Read more