I am not sure which solution here would work best as a solution but what I am looking for is just a simple way to enter an optional domain through a metabox on the page edit screen and then just select a template from the default page templates wordpress uses.
I am assuming there must be a simple way to accomplish this by manually adding an A name record for the new domain and pointing it to the same IP the main website is using and then through some code allow requests to this new domain to load a specific post ID while utilizing the specific page template you selected.
I would like for the page to be accessible for both domains and just the new domain would utilize the defined template.
How can this be done?
updated
I guess the other way would be to first setup a single page so it can have its own subdomain by using some built in wordpress code used for multisite? In other words, if a custom subdomain could be assigned to a specific post id then a cname record to this subdomain could be set for the new domain… Not sure the best way to accomplish this.
This code will allow you to set a custom meta value, and if the domain name (or subdomain if you edit the code) matches it, the query will be changed to match that post. The page template will only be used for that request, not for requests via the “normal” URL.
This does not change links on that page: should they go to the “normal” site or stay in the subdomain?
How you solve this on the DNS side is probably a Server Fault question.
Updated Answer
Okay, it sounds like you want an option in the write panel that will allow you to compose a post on Site A and, optionally, also publish that post to Site B. It sounds like an interesting project and it should be possible using WordPress and XMLRPC.
Here is some example code. By combining the code in this article with a custom meta box, you should be able to accomplish your goal. Good luck!
Here are some more good resources:
implements an XMLRPC solution, but
this requires you to publish in a
third-party environment.
N.B. To ensure updates you make to posts are syndicated, you may also want to store the post_ID of the post on the remote site in a custom field. You should probably also implement a delay of a few minutes before the initial remote post is sent (I know that I inevitably make changes immediately after publishing almost anything, but that may just be me).
Original Answer is Below
Either (i) setup .htaccess with mod_rewrite to mask the post URL, (ii) syndicate your posts across multiple sites using RSS with wp_insert_post or (iii) create a folder within your theme called post-redirect and add the following files to it:
post-redirect-meta.php – Create a meta box called “Post Redirect URL”
with a text input box that will save
to your postmeta table.
post-redirect.php – Create a theme template called “Post Redirect” which conditionally (based on the HTTP referrer) executes a 301 redirect using the target URL saved in the “Post Redirect URL” meta box on your post edit page. This will allow you to display the original post in a frame on the new domain.
Based on your stated requirements, these seem like the simplest solutions, but it’s far from clear that this is your intent (e.g. what does “I would like for the page to be accessible for both domains” mean? Are both sites running WP? What’s the business relationship between the two sites?). It would help if you more clearly explained the final result you are trying to achieve and a list of your most important concerns. Whatever your answer is to this, if possible, please also explain “why”.
The code to achieve this isn’t complicated, but before going through the trouble, please clarify what you’re trying to accomplish.