• I am writing a plugin that a) loads a lot of css/js and b) needs to modify the title (wp_title) based on the result of a call that the plugin will make. I have tried 2 things:

    1) use a shortcode: problem is that the css/js is loaded on every page regadless of the presence of a shortcode and the shortcode is also processed after the wp_title hook. I would ideally like to know if the shortcode will be loaded on my page and do some pre calls to get the info I need, load css etc… but the only methods I saw were crude and not so bullet proof of parsing the query post(s) for the shortcode – seems to not be a good method at all from what I read.

    2) Alternatively, since my plugin intends to be loaded on a full PAGE page then I can,, instead of using a shortcode, test for the correct page ID then do all my calls and insert the plugin result at the end of the page content. That is perhaps not as flexible but would be ok. However I am not sure how to test for a page id since the functions is_page() and is_page(X) evidently only work in the template and not in the plugin – they always return false in the plugin even though they return true in the template. Additionally the global $post variable does not seem to exist within the plugin context.

    This seems to be an issue that has been unresolved for a year according to my googling. Anyone have ANY ideas?

    Thanks

  • The topic ‘Load wp_title, css, js only when plugin activated’ is closed to new replies.