tjsix
Forum Replies Created
-
Forum: Alpha/Beta/RC
In reply to: RC6 TinyMCE Removing nested tagsExample:
<div class="atest" data-postid="12"><span class="button"></span>Div Content</div>Switching between Text/Visual in RC6 will strip out the span tag leaving only the parent div and it’s content. This does not happen in 3.4.2.
Forum: Alpha/Beta/RC
In reply to: MCE Editor stripping attributes and removing tagsAndrew, I didn’t originally post any code but can post anything you’d like.. the part where I noted what it gets replaced with is just a non-breaking space..
Forum: Themes and Templates
In reply to: custom fields and custom meta boxesIs it giving you any errors or just not saving the data you put in?
Forum: Themes and Templates
In reply to: custom fields and custom meta boxesIt’s probably because the $key is not defined.. define the key at the top, you can set it to whatever you want and it’s usually the shortname for the theme.. so just set it to $key = mytheme; or whatever.. the key just needs to be a unique identifier..
Also, in the create_meta_box and display_meta_box functions call the key in the global scope with global $key;
Forum: Themes and Templates
In reply to: custom fields and custom meta boxesYup, you just change the add_meta_box( ‘meta-box-id’, ‘The Title’, ‘display_meta_box’, ‘post’, ‘normal’, ‘high’ ); to page instead of post… (or add a second one) you could do two separate functions for displaying each differently, or just have them all display the same just display different info..
For instance in most of my themes I have two arrays, usually $meta_boxes_page and $meta_boxes_post and I add an additional two functions from what I posted above, display_meta_box_page and display_meta_box_post, each are essentially the same and just pass the arrays to my display_meta_box() function, and they are both called from the add_meta_box() function..
Forum: Themes and Templates
In reply to: custom fields and custom meta boxesI’m a little confused on what you’re asking, you want to add meta boxes to all of your pages/post types or just your custom ones? if you want custom fields that don’t neccesarily appear under the custom fields tab just do something like this:
//Put all your arguments and details in the array.. Example: $meta_boxes = array( "background_image" => array( "name" => "background_image", "title" => "Page Background Image", "type" => "text", "description" => "A background image for the page.") ); //Hook into the admin_menu add_action('admin_menu', 'create_meta_box'); function create_meta_box() { add_meta_box( 'meta-box-id', 'The Title', 'display_meta_box', 'post', 'normal', 'high' ); } //Display the meta_boxes function display_meta_box($meta_boxes) { $data = get_post_meta($post->ID, $key, true); <div class="form_wrap"> <?php foreach($meta_boxes as $meta_box) { <div class="form_field"> <label for="<?php echo $meta_box['name']; ?>"><?php echo $meta_box['title']; ?></label> <input type="text" name="<?php echo $meta_box['name']; ?>" value="<?php echo htmlspecialchars( $data[$meta_box['name']] ); ?>" /> <p><?php echo $meta_box[ 'description' ]; ?></p> </div> </div> } } //Function to save your fields add_action('save_post', 'save_meta_box'); function save_meta_box( $post_id ) { global $post; foreach( $meta_boxes as $meta_box ) { $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ]; } //Make sure the POST info came from WP.. if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) ) return $post_id; if ( !current_user_can( 'edit_post', $post_id )) return $post_id; update_post_meta( $post_id, $key, $data ); } }Obviously this can be expanded upon to display the form however you’d like but thats the gist of what needs to be done for any custom meta box info you want to add..