WordPress.org

Support

Support » Multisite » [Resolved] How to query over the network

[Resolved] How to query over the network

  • I have a WP 3.8.1 Multisite installation with 3 blogs, they’re all in one db, prefixed wp_, wp_2_ and wp_3_.

    In a template in wp_ I try to to display all posts from wp_, wp_2_ and wp_3_ which have a category xxx attached. I want to display the posts chronologically. I tried this query:

    SELECT *
    FROM $wpdb->posts
        	INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID= $wpdb->term_relationships.object_id
        	INNER JOIN $wpdb->term_taxonomy ON $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id
        	INNER JOIN $wpdb->terms ON $wpdb->term_taxonomy.term_id=$wpdb->terms.term_id WHERE $wpdb->terms.name = 'xxx'
        ORDER BY $wpdb->posts.post_date DESC

    This works only for the current blog, ie it doesn’t include wp_2_ and wp_3_.

    How do I retrieve all posts with category xxx from wp_, wp_2_, wp_3_ (instead of only wp_)?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How to query over the network’ is closed to new replies.