WordPress.org

Ready to get started?Download WordPress

Forums

query sub site recent blog post for main blog home page (4 posts)

  1. holotrope
    Member
    Posted 2 years ago #

    I want to grab the most recent custom post type of a sub site blog and display it on the home page of the main blog. I looked at using http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/ but that isn't working for me (nothing is being brought to main site that I can tell).

    I was hoping to just use something like query_posts('blogid=2&post_type=customposttype') but that doesn't work either. I can get the custom post type of the main site but not the subsite post.

    Any ideas?
    Thanks!
    Tom

  2. The posts are custom post types and not normal posts, then?

  3. holotrope
    Member
    Posted 2 years ago #

    Correct. I'm currently working on using something like:

    global $wpdb;
    $wpdb->set_blog_id(2);
    
     $querystr = "
        SELECT $wpdb->posts.*
        FROM $wpdb->posts, $wpdb->postmeta
        WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
        AND $wpdb->posts.post_status = 'publish'
        AND $wpdb->posts.post_type = 'customposttype'
        AND $wpdb->posts.post_date < NOW()
        ORDER BY $wpdb->posts.post_date DESC
    	LIMIT 1";
    
     $pageposts = $wpdb->get_results($querystr, OBJECT);

    Then looping through. However, the permalink doesn't work the way you would think it should and I still haven't gotten any meta data to go with it. It would be great to get the custom fields and featured image too.

    Thanks!

  4. That makes a certain amount of sense. I know thw plugin wasn't made to handle CPTs from inception.

Topic Closed

This topic has been closed to new replies.

About this Topic