• Resolved chando6000

    (@chando6000)


    Hi

    is there a way to use a shortcode to display the title of the page a user is currently on. I want to create a type of banner at the top of a page that displays the page name the user is on, i want to use a page builder to achieve this and that’s why I want to use a short code. or can this only be achieved through php.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You’d need to create a shortcode, so that involves PHP.

    Something like:

    function my_title() {
       return get_the_title();
    }
    add_shortcode( 'title', 'my_title' );

    Then you’d use [title]to report the current global post’s title.

    Thread Starter chando6000

    (@chando6000)

    Hi @sterndata

    works perfectly. exactly what i needed.

    thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘display pages and post title’ is closed to new replies.