How to add a default predefined thumbnail when creating a brand new post?

I found an adequate solution. Generally, I used the save_post_{$post->post_type} hook which gave me a $post_ID and a $post object. I was just checking to see if there was a thumbnail and if is not there to add it. That is all. add_action( ‘save_post_book’, function ($post_ID, $post){ if ( get_post_meta($post_ID, ‘_thumbnail_id’, true) ) : return; … Read more

Get all image in media Gallery with alt/title?

<?php /* * Template Name: Gallery Page */ $query_images_args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => – 1, ); $query_images = new WP_Query( $query_images_args ); ?> <?php get_header();?> <div class=”main”> <div class=”row”> <?php foreach ( $query_images->posts as $image ) {?> <div class=”col-md-3″> <?php echo wp_get_attachment_image( $image->ID,’thumbnail’ );?> </div> <?php … Read more

submit two file input fields in the same form

Here’s what I think is happening. I’ve added comments to the relevant sections of your code. // You use the $_FILES superglobal to get the uploaded files. if (isset($_FILES[‘file_metabox’])) { $file_metabox = $_FILES[‘file_metabox’]; foreach ($file_metabox[‘name’] as $key => $value) { if ($file_metabox[‘name’][$key]) { // … // Here you **overwrite** the $_FILES superglobal. $_FILES = array(“file_metabox” … Read more