[post_title]

The shortcode is designed to dynamically display the title of a post, page, or custom post type.


Product


Shortcode Attributes

  1. id – The ID of the post whose title you want to display. If not provided, the current post ID is used.
    • Options: Any valid post ID.
  2. first_word_only – If set to on, only the first word of the title will be displayed.
    • Default: off.
    • Options: on or off. Specify one only.
  3. prepend – Text to add before the title.
    • Options: Any text value.
  4. append – Text to add after the title. If the title ends with “s”, the text will not be appended.
    • Options: Any text value.
  5. label – A label to display before the title.
    • Options: Any text value.

Shortcode Enclosed Content

Any content placed between [post_title] and [/post_title] will be used as a template, where {content} acts as a placeholder for the post title.


Example Usage

[post_title]
[post_title id="123"]
[post_title first_word_only="on"]
[post_title prepend="Hello, " append="!"]
[post_title label="Title: "]
[post_title]<h1>{content}</h1>[/post_title]

Results

Example 1:
Display the Current Post Title.

Example 2:
Display the Title of Post with ID 123.

Example 3:
Display Only the First Word of the Title.

Example 4:
Add Text Before and After the Title: Hello, The Title of the Current Post!

Example 5:
Add a Label to the Title: Title: The Title of the Current Post.

Example 6:
Use Custom Content with the Title: <h1>The Title of the Current Post</h1>
If the id attribute is provided, the shortcode uses that post ID.
If the current post is of type location_post or location_page, it retrieves the linked location’s ID using _get_field_value(‘link_to_location’). Otherwise, it defaults to the current post ID.