WordPress Change title from plugin based on post or page ID

Hi Guys,

There are times when you write a plugin that has to create a page and the page contents would be a shortcode handled by your plugin.

Now when thats the case your landing page title will always be the same.

Question is how we can change it depending on your post or page ID.

This post will just give you an Idea but the final pen up has to be done by you.

Look at the function below that defines a filter function that you will modify and add it to your plugin file

Few assumptions in the above code but as a plugin dev you will understand what those are

Now In you main plugin file just add filter to handle filter hook called wp_title as shown below


That pretty must it. Now if you are in doubt please use comments to ask questions so that others including myself can reply.

I hope this helps



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.