Tag Info

Hot answers tagged

2

Resolved by following comment on Tutsplus Tutorial (link included): In function save_meta(), replace this line: if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) with this line: if (!isset($_POST['custom_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) See full comment here.


2

To save: // Update and save the field so it can be used in our template if ( isset( $_POST['input_name'] ) ) { $data = sanitize_text_field( $_POST['input_name'] ); update_post_meta( $post_id, 'field_name', $data ); } To read: $data = get_post_meta( $post_id, 'field_name', true ); // With post object, a leaner, cleaner method: $data = ...


2

I am a little confused as to your question. If you know how to create shortcodes with attributes, then I think the answer to your question is to simply output text with the correct attributes predefined. For example, just add text into your custom column for the appropriate arguments, such as echo "[book id=" . $post->ID . "]". The shortcode isn't ...


1

Short answer: no. WordPress core has the basic meta box functionality (registering a box & passing a callback) - what that callback does, or how it works, is entirely up to you. You can either code your own implementation, or use a 3rd party as you mentioned.


1

Have you noted that you are verifing that the post type is a page and that user can edit pages and posts? if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return; } It should be: if ( 'ranch' == $_POST['post_type'] ) { if ...



Only top voted, non community-wiki answers of a minimum length are eligible