I am writing my first humble plugin, which gets items from a simple database. For good SEO, I want to set the HTML title to be the item name, varying according to my users choice.
My user enters some choices on a form and I show results. Each item has one page and the URL gives me
?item=12345 so I can get the item name from my database. All this works.
I can successfully set the title, by setting up this in my top (“bootstrap”?) file of my plugin:
add_filter( 'pre_get_document_title', 'dwnz_filter_pagetitle', 20 );
to call my function (which queries the database for the item name).
My problem is: this filter is being invoked through the whole website, not just when my plugin is being used. How do I limit this call just to my plugin pages?