[wp-hackers] Reinvoke wordpress

Jonathan Brinley jonathanbrinley at gmail.com
Wed May 8 19:34:25 UTC 2013


Coincidentally, I just did something like this. Sorry, I can't share
the code, but the gist of it is I have two sites, A and B. If I land
on a page at B that doesn't exist (I check this during parse_request),
I pull the content from A (assuming it exists there). I then use the
WP Router library (https://github.com/jbrinley/wp-router) to hijack
the query and insert that content:

$wp->query_vars = array(
  WP_Router_Page::QUERY_VAR => $wp->request,
);
new WP_Router_Page($content, $title,
get_template_directory().'/my-template.php');

Have a nice day,
Jonathan


On Wed, May 8, 2013 at 12:18 PM, Dobri <dyordan1 at ramapo.edu> wrote:
> Hey guys,
>
> I know this might be a weird question but I've got a weird client:
>
> I have a multi-site installation. When a non-existing site slug is encountered, I reach the 404.php page and just before saying "nope, doesn't exist", I do some checks. If they work out, I would like to display some content from another site the same way it would have been displayed by wordpress if requested properly, going through all the templates and post_types and all of that fun stuff. So far, I have managed to detect if everything checks out and use switch_to_blog() to switch to the appropriate blog. Is it possible to reach my end goal with this? In essence, when I reach the 404 and I check and everything is in order, I want to reinvoke WordPress, just with a different request on a different site. Redirecting doesn't work since there is a mix of static files and wordpress sites and redirecting would link to the static files (precisely the reason I'm doing this). So… ideas?
>
> ~Dobri
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



-- 
Jonathan M. Brinley

jonathanbrinley at gmail.com
http://xplus3.net/


More information about the wp-hackers mailing list