• Resolved wasanajones

    (@wasanajones)


    I need to create a shortcode to return the post title in the body of the content.

    with PHP enabled <?php the_title(); ?> returns what I want, but it gets stripped by WP and is a security risk to enable PHP.

    1) is there a Shortcode generator plugin for PHP functions?

    2) what would be the specific code for functions.php to make this work?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Check Generate WP. There’s also the Shortcodes Generator plugin but it’s compatible (tested) only up to WP 3.4.2

    Thread Starter wasanajones

    (@wasanajones)

    thanks for that lead — nice resource

    it didn’t quite answer what I needed but it did prompt me to use better search terms for looking into this

    stackoverflow had this snippet to add to functions.php which gave me just what I needed

    function myshortcode_title( ){
       return get_the_title();
    }
    add_shortcode( 'page_title', 'myshortcode_title' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode for Post Title in Content’ is closed to new replies.