Front end post and upload file, image for users without plugin

Use wp_handle_upload in a custom function if ( $_FILES ) { upload_user_file($_FILES[‘test_upload’]); } if ( ! function_exists( ‘upload_user_file’ ) ) : function upload_user_file( $file = array(), $title = false ) { require_once ABSPATH.’wp-admin/includes/admin.php’; $file_return = wp_handle_upload($file, array(‘test_form’ => false)); if(isset($file_return[‘error’]) || isset($file_return[‘upload_error_handler’])){ return false; }else{ $filename = $file_return[‘file’]; $attachment = array( ‘post_mime_type’ => $file_return[‘type’], ‘post_content’ … Read more

How do I save Multiple fields in a meta box?

I would suggest you define a field names property on your class: class your_class { private $_fields = array( ‘firstname’, ‘lastname’, ‘sex’, ); public function prfx_meta_save ( $post_id ) { } } Now you can fully abstract your save handler: foreach ( $this->_fields as $field ) { if ( ! isset( $_POST[ $field ] ) … Read more

Adding metaboxes to attachment pages

get_post_meta returns an array when you set the 3rd parameter to false, so $value is an array in your metabox callback and you’re treating it as string. I assume an attachment has a single value for license, so you want to set that to true instead.

Metabox Keeps Stripping Parts of Shortcode

I really should get some sleep 😛 The shortcode is [masterslider] and I manually wrote [metaslider].. That meta box must’ve gotten into my mind.. Just change the appropriate line to this: value=”<?php echo esc_html($value); ?>”> and it works. Thanks @Howdy_McGee for pointing me to the right direction! Also @s_ha_dum for additional knowledge.

Display custom meta on page that has been check in custom post type

You just want a meta_query based on the current page’s ID: $query = new WP_Query( array( ‘post_type’ => ‘sidebar_boxes’, ‘posts_per_page’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘key’ => ‘checkfieldBox’, ‘value’ => $post->ID, ) ) ); You can really only depend upon $post in the way I did on “singular” pages … Read more