• 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. This code exists in the PHP on my page. I just need to be able to change the meta description and page title on the fly with POST data but only when POST data defined for use as title exists.

    add_filter(‘wp_title’, ‘set_page_title’);

    function set_page_title($orig_title) {
    return ‘Modified ‘ . $orig_title;
    }

Viewing 1 replies (of 1 total)
  • I think the reason is that the PHP you are using in your Page is executed after the title has been processed. If you put your filter function in functions.php, it should work.

    You will probably need to add code in the function to get the post content ($post->content) and check it there.

Viewing 1 replies (of 1 total)
  • The topic ‘modify page title using post data and inline php’ is closed to new replies.