Skip Navigation

[Resolved] Add ShortCode to Post Title

This thread is resolved. Here is a description of the problem and solution.

Problem:
Can I add a ShortCode into the WordPress Post Title?

Solution:
Adding ShortCodes to the Post Title is not possible, in WordPress.
Post Titles have to be "strings" so later you can display that with a Shortcode ( [wpv-post-title]) but you cannot add a shortcode to the title itself.

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 5 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#1204088

I am trying to:

Hi,

I’ve got the following toolset shortcode that outputs a date from a custom field added to a specific post when I use the Elementor shortcode module on a page:

[types field='this-week-start-date' style='text' format='F j, Y' post_id='1345'][/types]

I can’t edit the style of this though in the shortcode editor window or even by adding custom css (unless I’m making a basic mistake) and I don’t want a separate module to display this info, I want to insert it into existing title and text fields along with text so the shortcode results become part of the text.

So for example a title field on a page needs to show WEEK BEGINNING 18th February 2019 and I want to manually type WEEK BEGINNING then add [types field='this-week-start-date' style='text' format='F j, Y' post_id='1345'][/types] so the result would be WEEK BEGINNING 18th February 2019 whereby the shortcode puts the date in and it will be styled in the style of the title module.

Why do I want to do this? I don’t want editors to have access to edit Elementor pages so I’ve created a CPT that will only have one post. The fields of this post show 2 telephone numbers, an email address, a twitter name and two week beginning dates for a schedule page. This ‘sitewide’ info will be placed onto various pages so that when dates and phone numbers change, editors can edit the single post and the revised info will then show throughout the site on various pages by virtue of the shortcodes.

So is there a way to manually enter WEEK BEGINNING [types field='this-week-start-date' style='text' format='F j, Y' post_id='1345'][/types] but the result show as e.g. WEEK BEGINNING 18th February 2019. So far when I try this, the shortcode is displayed, and not the date.

Many thanks,
Barry.

Link to a page where the issue can be seen:
hidden link

I expected to see: in the SCHEDULE section of the page linked to above there are blue 'week beginning' titles. Underneath that, grey dates which are the shortcodes. Instead I want the shortcodes to be placed in the blue title fields so the date shows next to 'week beginning'.

Instead, I got:

#1204336

I am not sure to understand, however adding ShortCodes to the Post Title is not possible, in WordPress.
Post Titles have to be "strings" so later you can display that with a Shortcode ( [wpv-post-title]) but you cannot add a shortcode to the title.

Now, if you want to add ShortCodes to Elementor's templates you will just be able to insert them anywhere you like and Elementor offers them.

But I am not sure where you added it to control if that's done correctly.

Can you link me to the Post or Page where the issue happens and where you edit it?
Then I can see what is wrong with it.

I might need to make edits, please either confirm that I am allowed to make edits on the live site or provide access to a staging server.

Thanks!

#1204490

Hi Beda,

Thank you for explaining this. I understand now about the title and string. I can see that my shortcode does work in a text editor module (which I can style to look like a title anyway....) so thanks to your explanation, all is working fine now.

Many thanks,
Barry.

#1204496

Great, hence we can close here.

Thanks!