Site logo

Archived topic

Change page title programmatically

3 replies · Started by _blank on July 26, 2020

Viewing posts 1–4 of 4

Hi,

I'd like to change titles of some pages without changing metadata stored in a database but rather to create and display a page title dynamically (based on e.g. embedded custom post id, etc.). What would be the optimal way to do it in GP?

Peter

Hi there,

WordPress uses the_title() function to output the title. That function has the_title filter, however WordPress uses the same filter for things like widget titles and menu item titles, so it's nearly impossible to target the content title, unfortunately.

Your best bet would be to disable the standard title and add your own title function into the page using Elements. That way you could conditionally load the title based on your own parameters.

Let me know if you need more info :)

Ok thanks for the hints, I will play around :)

Sounds good - let me know if you run into any issues :)

This archived topic is closed to new replies.