Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
are $blog_id and $post_id in the scope? and also this code alone wont display the content. –  Bainternet Aug 19 '12 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.) –  Calle Aug 19 '12 at 22:10
2  
try get_header as your hook –  Bainternet Aug 19 '12 at 22:16
    
Yup, that works. Thank you. –  Calle Aug 19 '12 at 23:05
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.