• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Rachel Lynn

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password
  • Profile
  • Topics Started
  • Replies Created
  • Engagements
  • Favorites

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • October 11, 2017 at 1:20 pm in reply to: Add Meta Box/Subtitle #212429
    Rachel Lynn
    Participant

    Yes, 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. 🙁

  • Author
    Posts
Viewing 1 post (of 1 total)

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble