• Ruben

    (@rubenvankempen)


    Hi there,

    Perhaps I have a basic question: how can I use a shortcode to display the current page title?

    Thanks!

    I’ve already tried it by adding this code to functions.php, but that did not work for me:

    function page_title_sc( ){
       return get_the_title();
    }
    add_shortcode( 'page_title', 'page_title_sc' );

    and shortcode

    [page_title]
    

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Good morning,

    Can you try this code to your functions.php instead:

    add_shortcode( ‘px_post_title’, ‘px_post_title’ );
    function px_post_title() {
    $post_title = get_the_title($post = 514);
    return $post_title;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Display Post Title with shortcode’ is closed to new replies.