Showing Meta Box via Jquery Checkbox

Found a solution to it though, pretty simple <script type=”text/javascript”> jQuery(document).ready(function($) { var dw_match_display = $(‘#dw_match_display’); dw_match_display.hide(); if ($(‘#dw_complete’).prop(‘checked’) ) { dw_match_display.show(); } $( ‘#dw_match_details’ ).on( ‘change’, ‘#dw_complete’, function() { dw_match_display.hide(); if ( $(this).prop(‘checked’) ) { dw_match_display.show(); } }); }); jQuery(document).ready(function($) { $( ‘#dw_match_display’ ).change(); }); </script>

Saving meta box data?

What you are trying to do is not going to work the way you are trying to do it because on post save WordPress will process the data and then redirect back to the originating page. That means that any global you set before the redirect isn’t going to be there afterwards. However, your custom … Read more

Output list from each line of metabox (shortcode)

You missed $output in “for” loop, wrong $project(s) name. add_shortcode( ‘cv’, ‘vp_cv’ ); function vp_cv( $atts, $content = null ) { //….. while( $query->have_posts() ) : $query->the_post(); $title = get_the_title(); $projects = get_post_meta($post->ID, ‘resume_projects’, true); if( $projects ) $projects = explode(“\n”, $projects); $output .= ‘<p class=”cv-title”>’ . $title . ‘</p>’; $output .= ‘<p class=”cv-projects”>’; $output … Read more

I can’t connect my custom jquery to wp admin

Because YOU CAN’T DEREGISTER JQUERY IN THE ADMIN Why would you even want to? See src: http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/functions.wp-scripts.php?order=name#L105 // Do not allow accidental or negligent deregistering of critical scripts in the admin. Show minimal remorse if the correct hook is used. if ( is_admin() && ‘admin_enqueue_scripts’ !== current_filter() ) { $no = array( ‘jquery’, ‘jquery-core’, ‘jquery-migrate’, … Read more

CMB select with data from CPT

Use a function that returns an array of arrays that the options field expects. Something like this (untested code): array( ‘name’ => ‘Test Select’, ‘desc’ => ‘field description (optional)’, ‘id’ => $prefix . ‘test_select’, ‘type’ => ‘select’, ‘options’ => get_myposttype_options(‘myposttype’), ), function get_myposttype_options($argument) { $get_post_args = array( ‘post_type’ => $argument, ); $options = array(); foreach … Read more

Save JSON object attributes to custom metabox

I’ve found a possible solution. Not sure if it is safe though jQuery(function(jQuery) { // Uploading files var file_frame; var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id var set_to_post_id = 5; // Set this formfield = jQuery(this).siblings(‘.custom_upload_image’); preview = jQuery(this).siblings(‘.custom_preview_image’); // Create the media frame. file_frame = wp.media.frames.file_frame = wp.media({ multiple: false // Set … Read more

HM CMB: Role Select

There is a list of roles in the $wp_roles WordPress global object. Set $wp_roles to a global at the top of your method of function: global $wp_roles; Use a Select Field to populate the options: array( ‘id’ => $prefix . ‘role’, ‘name’ => ‘Role’, ‘type’ => ‘select’, ‘use_ajax’ => false, ‘options’ => $wp_roles->get_names(), ), Note: … Read more