Forum Replies Created
-
AuthorPosts
-
Rachel Lynn
ParticipantYes, I understand that they are not standard. I guess I didn't express myself clearly. I would like to be able to enter text (on a case by case basis) into a subtitle box. Something that can be entered manually just below the title (i.e subtitle). I tried adding this code to my functions.php
function your_sub_title() { add_meta_box('your_sub_title_metabox', 'Edit Sub Title', 'your_sub_title_metabox', 'post', 'normal', 'default'); ## Adds a meta box to post type } function your_sub_title_metabox() { global $post; ## global post object wp_nonce_field( plugin_basename( __FILE__ ), 'your_sub_title_nonce' ); ## Create nonce $subtitle = get_post_meta($post->ID, 'sub_title', true); ## Get the subtitle ?> <p> <label for="sub_title">Sub Title</label> <input type="text" name="sub_title" id="sub_title" class="widefat" value="<?php if(isset($subtitle)) { echo $subtitle; } ?>" /> </p> <?php } function sub_title_save_meta($post_id, $post) { global $post; if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return false; ## Block if doing autosave if ( !current_user_can( 'edit_post', $post->ID )) { return $post->ID; ## Block if user doesn't have priv } if ( !wp_verify_nonce( $_POST['your_sub_title_nonce'], plugin_basename(__FILE__) )) { } else { if($_POST['sub_title']) { update_post_meta($post->ID, 'sub_title', $_POST['sub_title']); } else { update_post_meta($post->ID, 'sub_title', ''); } } return false; } add_action('save_post', 'sub_title_save_meta', 1, 2);
and this code to the post.php
$subtitle = get_post_meta(get_the_ID(), 'sub_title', true); if(isset($subtitle)) { echo $subtitle; }
It does nothing. But, I noticed that there is already this last bit of code written in the post.php. Not sure exactly where to go from here. Probably should scratch all this and start over. I am new to Genesis and my abilities are less than top-of-the-line (to say the least). I had a few courses and understand code when I read it, and can stumble my way through most things that I want, but don't get all the nuances. Changing themes has made it harder on me. 🙁
-
AuthorPosts