I've created a custom post type for my landing pages, which each sit at www.mydomain.com/lp/<page-name>/
I want to keep those custom posts there, so they show up with proper featured images and excerpts on archive and search pages. However, in some cases, if someone goes to a specific page, I want it to load a static page, and associated style sheets and scripts from the directory where the static page is.
So, imagine the following URI hierarchy:
www.mysite.com/lp/page-a/
/page-b/ // this page exists in WP for search/archive purposes
/page-c/
The above pages all exist in WordPress and work fine. Now, there could be a directory structure on the server like
/vhost/mysite/www/wp-content
/wp-includes
/foo/page-b.html
/page-b.css
/public/page-b.js
If someone navigates to /lp/page-x/
, if page-x.html
exists in /foo
, I want it to load that, and I want relative references internal to page-x.html
(e.g., <script id="page-x-js" src="./public/page-x.js" defer></script>
) to pull from that directory path. But if they go to www.mysite.com/lp/page-a/
and /vhost/mysite/www/foo/page-a.html
doesn't exist, I want WordPress to load the normal, internal custom post.
The directory structure doesn't really matter — I have full control over the server. And while I assume this is some .htaccess
magic, I'm running Apache and can make changes to the config, or I could even add code to my plugin that creates the custom pages.
Anyone know how I can accomplish this?
/page-x/
" - Presumably you mean/lp/page-x/
? Presumably<script id="page-x-js" src="./public/page-x.js" defer></script>
does not exist in the WordPress generated page?/lp/page-x/
, and will update it in the post. Said script will not exist in the generated page, though other relative paths which don't start with.
may exist in both.