Put shortcode into a page / post title (including displaying code into the browser page tabs!)

Est. Reading: 1 minute
By: saqibnoor
Created: 01/13/2018
Category:
Difficulty: Intermediate

Put shortcode into a page / post title (including displaying code into the browser page tabs!)

×Warning: This tutorial was created 2288 days ago. Some of the information may be out of date with more recent versions of Formidable. Please proceed with caution and always perform a backup before adding custom code.

In order to dynamically create page titles, use the following code snippet:

add_filter( 'the_title', 'do_shortcode' );
add_filter('widget_text', 'do_shortcode');
add_filter('document_title_parts', 'wpmu_doc_title_shortcode', 10);
function wpmu_doc_title_shortcode($title) {
$my_title = $title['title'];
$my_title = do_shortcode($my_title);
$title['title'] = $my_title;
return $title;
}

You can then plan how you use it, I did this for a dynamic page title:

In page / post title, I used: [frm-field-value field_id=627 entry="entry_param"]

My link to the dynamic page has the url including the ?entry_param=[id] tag

Anyhow all works nicely

Leave a Reply

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crosschevron-leftchevron-rightarrow-right