[Resolved] Is there a GP shortcode or preferred method to print the Page Title?

Home Forums Support [Resolved] Is there a GP shortcode or preferred method to print the Page Title?

Home Forums Support Is there a GP shortcode or preferred method to print the Page Title?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1627432
    Henry

    I am using a custom post type and I need to add the Post Title to my template. I know that you can hard code that into a template but I prefer to use a shortcode like this:

    function post_title_shortcode(){
        return get_the_title();
    }
    add_shortcode('post_title','post_title_shortcode');

    Just asking in case there is a “preferred” way?

    Much the same way that GP has a copyright date shortcode right? Is there something similar for the Post Title?

    I don’t want to duplicate efforts, hence the question, thanks.

    #1627500
    David
    Staff
    Customer Support

    Hi there,

    no GP doesn’t add ANY shortcodes. So the method you’re using is correct.
    Although if you’re adding that to a template then you’re better off just making the function call for the title as opposed to wrapping it in a shortcode..

    #1636438
    Henry

    thanks David

    #1636582
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.