1

Anyone thinks this should not work? I can't make it work for some reason.

add_action( 'wp_head', function() {
    switch_to_blog( $blog_id );
    wp_query( 'p=' . $post_id );
});

The point is that instead of displaying whatever page I am about to display, I choose content from a different blog instead.

3
  • are $blog_id and $post_id in the scope? and also this code alone wont display the content.
    – Bainternet
    Aug 19, 2012 at 21:45
  • $blog_id and $post_id are just placeholders for my example, so yes they are in the scope. This code will not in itself display the content, but further down the line the "Wordpress loop" will do it. Right? (I'm not getting 404, I actually display a page template but there is not content in it, one possible reason for this not working is that it's not getting invoked. But I think the hook is suitably chosen.)
    – user5028
    Aug 19, 2012 at 22:10
  • 2
    try get_header as your hook
    – Bainternet
    Aug 19, 2012 at 22:16

1 Answer 1

0

For other people with the same issue who don't read comments the solution was to change the hook from wp_head to get_header

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.