How to get all pages on specific blog after switch_to_blog?
Try using get_posts instead of get_pages $pages = get_posts( array( ‘order’ => ‘ASC’, ‘orderby’ => ‘ID’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ) );
Try using get_posts instead of get_pages $pages = get_posts( array( ‘order’ => ‘ASC’, ‘orderby’ => ‘ID’, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ) );
fatal Error undefined function switch_to_blog()
switch_to_blog($blog_id); still writing to main blog
Your code, which I assume is in a function, should pass variables needed from the current blog. So, assuming that your code in your question is called by somefunction(), change that to pass along variables from the current blog, as in // variables from the current blog $current_blog_1 = “some value” $current_blog_2 = “another value” … Read more
You are looping through the posts queried before your switch_to_blog() statement. Your code appears to be from a page template which is executed AFTER the main query has run. To be clear, the main query is run before the template code is executed. Switching to another site after that does not update the query, therefore … Read more
How to get tags from different blog?
switch_to_blog() + do_action(‘generate_footer’) not working in multisite
Just keep in mind this is only going to get you the image ID, but it should do the trick… does in my circumstance at least. // switch to the correct blog switch_to_blog( $site -> blog_id ); // pull in our db global global $wpdb; // get the image ID $_image_id = $wpdb -> get_col( … Read more
Edit: You have an extra underscore in your table name, it becomes wp__posts in your case. Better use like how I have shown below 🙂 First, use table names like the following and try var_dump to see if it returns NULL. In case the Post ID doesn’t exist, $product will be NULL, which only var_dump … Read more
Hook into ‘pre_insert_term’, $term, $taxonomy and dump the global $blog_id; to see if you’re on the right place: function wpse_inspect_blog_id( $term, $taxonomy ) { global $blog_id; var_dump( $blog_id ); exit; } function wpse_hook_inspector_blog_id() { add_filter( ‘pre_insert_term’, ‘wpse_inspect_blog_id’ ); } add_action( ‘init’, ‘wpse_hook_inspector_blog_id’ );