Title: Modify Title Within Shortcode Function
Last modified: August 22, 2016

---

# Modify Title Within Shortcode Function

 *  [Rustaurius](https://wordpress.org/support/users/rustaurius/)
 * (@rustaurius)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/modify-title-within-shortcode-function/)
 * Hi,
 * I’m looking to potentially modify the page title within a shortcode, depending
   on a saved setting. I can’t get my head around what I should be calling. Here’s
   what I’ve tried so far:
 *     ```
       if ($Filter_Title == "Yes") {
         add_filter('the_title', 'Alter_Title', 20, $ProductName);
       }
       ```
   
 * Those lines are within a shortcode that is working normally. The code doesn’t
   seem to work, so any thoughts on where/how I should be adding the call to the
   filtering function would be appreciated!

Viewing 1 replies (of 1 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/modify-title-within-shortcode-function/#post-5206775)
 * I think that by the time your shortcode gets processed, that the title has come
   and gone, you are too late to process it.
 * Your Alter_Title function needs to be installed earlier, possibly in a customised
   page template, or in functions.php itself. You may need to add some conditional
   code within your filter so that I knows when to pass the title through unchanged
   and when to process it.

Viewing 1 replies (of 1 total)

The topic ‘Modify Title Within Shortcode Function’ is closed to new replies.

## Tags

 * [add_filter](https://wordpress.org/support/topic-tag/add_filter/)
 * [plugin-development](https://wordpress.org/support/topic-tag/plugin-development/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/modify-title-within-shortcode-function/#post-5206775)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
