Media Upload Directory to MMYY instead of YYYY/MM

/** Force wp_upload_dir() to use time-based paths. */ add_filter( ‘pre_option_uploads_use_yearmonth_folders’, ‘__return_true’ ); /** * Use the date format MMYY instead of YYYY/MM in the uploads path. * * @param array $dir * @return array */ function wpse_104005_upload_dir( $dir ) { if ( preg_match( ‘!/([0-9]{4})/([0-9]{2})!’, $dir[‘subdir’] ) ) { // Check we do indeed have a … Read more

Metabox nonce not allowing update

The issue was that you should have changed product_noncename to goal_info_meta_box_nonce. I’ve also made a few other changes, commenting out the old lines for comparison, which should avoid any further errors (including the undefined index). // verify nonce // if ( ! isset( $_POST[‘product_noncename’] ) || ! wp_verify_nonce( $_POST[‘goal_info_meta_box_nonce’], basename( __file__ ) ) ) { … Read more

How to fetch all videos in custom page which uploaded in wp-admin (Media) in wordpress

Uploaded images, video’s etc. are stored as posts with the type “attachment”; use get_posts( ) with the right parameters. Try this; the code loops trough all attachments and displays them: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => null, // any parent ‘post_mime_type’ => ‘YOUR-POST-MIME-TYPE’ ); $attachments = get_posts( … Read more