I am building a plugin, but despite several search parameters, I cannot figure out how to replace a page's content with custom content generated by my plugin.

I have already written several shortcodes and widgets, but I'd like to replace the whole page.

The best example I have is CiviCRM. When the plugin gets installed, it generates a placeholder page which is replaced by custom content, I believe based on the query string.

I assume there's an add_action or similar add_ function I need to call for the plugin function to be called when the page loads.

  • You would just need to keep a record of the ID of the page that is your placeholder, and then use the the_content filter. – Jacob Peattie Jul 6 at 4:45
  • @JacobPeattie Thank you for that. Having read a little more about it, I can now see how to do it. I guess I was expecting to attach the filter to a specific page, but I guess I have to have it run on every page to check for the one I need. Seems a little inefficient, but that seems to be the process. Thanks. – Prdufresne Jul 7 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.