• I need to create a custom WordPress plugin that “talks” with a separate PHP application. When the user types a URL that does not exist on WordPress, I want WordPress to check whether my other PHP app has some HTML content to render (if yes, then render it) before WordPress throws a 404 error.

    Here is the current file structure:

    mysite.com -> a basic WordPress site
    mysite.com/app -> a complex php app (PHP, MySQL, CodeIgniter)

    When the user visits a page that does not exist on my WordPress, i.e:

    mysite.com/user.profile/

    I want WordPress to run a function (before the 404 error) that checks whether the app has some valid html data to render in that specific page. If the app responds with some HTML, render it, if not, display the 404 error.

    QUESTIONS:

    1) How can I accomplish this with a custom WordPress plugin? (hooks, filters, etc that I should keep into consideration? – I’m not a WordPress plugin expert)

    2) Should I write an API or use a dirty PHP include to let 2 systems talk to each other? (they’re on the same server as shown in the file structure)

    3) Sitemap: this is a tricky question for developers. Do you think that it would be easier to generate a separate sitemap (for those pages only) via the /app or via WordPress?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use the “template_include” filter to see if WP wants to use a 404 template and do supplemental checks before giving up. Whatever path your callback returns will be immediately included, so you can hand off execution to another app’s PHP file here, or go to a custom interface script that in turn queries the other app.

    Any WP plugin that dynamically serves sitemaps is only going to list WP resources. Some such plugins provide hooks where you can add in your own links in addition to whatever the plugin does. The specifics and availability depend on which plugin you use.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WordPress plugin structure – 404 replacement feature’ is closed to new replies.