How to get custom metabox image field?
Normally, the WordPress function for displaying the image of your custom meta box is this <?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?>
Normally, the WordPress function for displaying the image of your custom meta box is this <?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?>
selected() was big help for setting a default value. The rest I found in this brilliant meta box tutorial: http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes–wp-20336 with examples for text input, checkboxes and dropdown. Also Custom post type’s slug gets wrong when adding a custom meta box explained me how to correctly handle the current post object so it doesn’t get … Read more
I wonder if you want to modify the HTML of the inserted image, with the image_send_to_editor or get_image_tag filters? If that’s the case, then here’s one example: /** * Add the data-ext-link-title and data-ext-link-url attributes to inserted images. */ add_filter( ‘image_send_to_editor’, function( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if( $id > … Read more
Yes there are lot of ways you can achieve this by using plugin or pragmatically This Plugin will create custom content types as well as custom fields for specific content type: https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/ However you can also do this via pragmatically: http://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes–wp-27645 You can also check these functions from WordPress Codex which can be helpfull for … Read more
To pass data from js back to PHP simplest way is use json_encode or, in WP, its wrappers wp_send_json, wp_send_json_error and wp_send_json_success. Usage example: On PHP side function get_latest_product_meta() { $post_id = (int) filter_input(INPUT_GET, ‘post_id’, FILTER_SANITIZE_NUMBER_INT); $post_id or wp_send_json_error(); // array_shift because when used like so `get_post_meta` return array of arrays… $data = array_map(‘array_shift’, get_post_meta($post_id)); … Read more
I think you have error in your query. Please try this: $posts = get_posts(array( ‘post_type’ => ‘events’, ‘posts_per_page’ => -1, ‘meta_query’ => array( ‘meta_key’ => ‘from_datetime’, ‘type’ => ‘DATETIME’, // You can also try changing it to TIME or DATE if it doesn’t work ‘meta_value’ => date( “F d, Y g:i a” ), ‘meta_compare’ => … Read more
Example code in add_meta_box() documentation uses save_post hook (at the very end of wp_insert_post() function) to add custom fields data from metabox. You must be using something like that already in your metaboxes, is it not appropriate place to validate your data?..
Definitely doable with tons of different ways to accomplish it. Basically, you can use a widget that allows for the execution of PHP or modify your theme files to execute PHP in the sidebar. The main function you will need is get_post_meta. You also need to access the post/page/CPT ID. You can use code like … Read more
Some notes before: This is only how I’d approach it – I’m not going to step more into detail, because basically it’s a list of plugins you’ll have to code. Build a Back-End page Use the function add_menu_page to add a page. Then build your management tables extending the WP_List_Table class: class WPSE_48824_List_Table extends WP_List_Table … Read more
Unfortunately not. The only way is to deregister the metabox, and then re-register it, supplying your own callback function which mimics the original metabox, but with your alterations (making sure the names of the inputs do not change). This method is outlined in these posts: custom post type taxonomies UI radiobuttons not checkboxes Custom-Taxonomy as … Read more