I am running a plugin from a WP page to execute PHP and it works great. I'd like to edit the page title and description based on POST data. I am already using POST data in the PHP code to alter the page output and it works great but if I try to insert POST data in the following function to alter the page it doesn't do anything. I just need to be able to change the meta description and page title on the fly with POST data.

This code exists in the PHP on my page:

add_filter('wp_title', 'set_page_title');

function set_page_title($orig_title) { 
    return 'Modified ' . $orig_title;

1 Answer 1


Put it in functions.php or at the top of the header.php in your theme. What I suspect is that the wp_title() method in header.php is already executed by the time your add_filter() is called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.