WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Query posts of multisite outside WP (3 posts)

  1. bitxl
    Member
    Posted 1 year ago #

    So I'm using a multisite WordPress install, and trying to query posts outside of wordpress.
    I'm doing so by including:

    define('WP_USE_THEMES', false);
    require_once($_SERVER['DOCUMENT_ROOT'].'/wp-blog-header.php');

    After that, I change the global $wpdb variable site id, blog id and table prefix:

    $wpdb->blogid = $id;
    	$wpdb->siteid = $id;
    	$wpdb->set_prefix($table_prefix);

    from there on I would like to use query_posts and looking at the query in $wp_query it has selected the correct tables for querying however even when I try is_category with a slug I know exists I get false.
    Are these functions, like is_category and query_posts using variables I haven't changed yet in order to query a perticular site of my multisite install?

    query_posts does work when no arguments are given... but when I try to give it a category id it gives no posts, even though they should be there...

  2. bitxl
    Member
    Posted 1 year ago #

    Thanks! Sometimes I find it really hard to find functions that are so obvious for wordpress by just google'ing for my problem, short codes had me looking for hours too... :(

Topic Closed

This topic has been closed to new replies.

About this Topic