• Skip to primary navigation
  • Skip to main content

Genesis Community

Resources for Genesis WordPress Theme Users

  • Facebook
  • Twitter
  • Slack
  • Wiki
  • Login
You are here: Home / Wikis / WordPress / Shortcode for Post Title

Shortcode for Post Title

/**
 * Post title shortcode.
 * `[post_title]` to use in the loop. Or `[post_title id="123"]` to get a specific post's title, by ID
 * 
 * @return  string  The post's title.
 */
add_shortcode( 'post_title', function( $atts ) {
    $atts = shortcode_atts( array(
        'id' => get_the_ID(),
    ), $atts, 'post_title' );
    return get_the_title( absint( $atts['id'] ) );
});
Source: https://genesiswp.slack.com/archives/C02N454K9/p1523464635000658

Posted by: Sridhar Katakam Category: WordPress Tags: mike hemberger, shortcode

« Add custom body class

Copyright © 2026 · Genesis Sample on Genesis Framework · WordPress · Log in