WordPress.org

Support

Support » Plugins and Hacks » WordPress MU Sitewide Tags Pages » [Resolved] [Plugin: WordPress MU Sitewide Tags Pages] Grabbing Custom Post Type Posts

[Resolved] [Plugin: WordPress MU Sitewide Tags Pages] Grabbing Custom Post Type Posts

  • justbishop

    @justbishop

    I’m using this tutorial to try to do the filter thing to pull posts from a custom post type into my SWT blog:

    http://wpmututorials.com/plugins/sitewide-tags-update/

    I placed the following in the functions.php of the theme of the child blog using the custom post type “auctions”, but the SWT blog (my main site) still is not importing the “auction” posts:

    function my_swt_post_type_filter( $auction ) {
    $auction[] = array( 'auctions' => true );
    return $auction;
    }
    
    add_filter( 'sitewide_tags_allowed_post_types', 'my_swt_post_type_filter' );

    I just used the code from THIS support forum topic and modified it as I thought correct, as suggested by someone in the comments of the tutorial I linked at the beginning of this post. I’m sure my code is incorrect, but figured I should give it a go and have a jumping off point before asking for help (help? Please?)

    ETA: I also created the “auctions” post type on my SWT blog, and added the above code snippet to the tags blog’s functions.php as well. No joy.

    http://wordpress.org/extend/plugins/wordpress-mu-sitewide-tags/

Viewing 15 replies - 1 through 15 (of 40 total)
  • Plugin Author Ron Rennick

    @wpmuguru

    You don’t need to have that filter active on the SWT blog. The filter needs to be active on the source site when the post is being published.

    When you registered the post type on the SWT blog, can you see the post type admin?

    Is your post type auction or auctions?

    justbishop

    @justbishop

    Yep, I have the custom post type on the SWT site, and it is showing in the admin menu. There are no posts being pulled into it. I have tried “auction” as well as “auctions”, and published completely new posts to the child blog I want them pulled from under all circumstances I’ve tried. Still not being pulled into the SWT blog.

    The “auction” type posts are also not being picked up by the BuddyPress activity stream.

    But isn’t my code wrong somehow?

    Plugin Author Ron Rennick

    @wpmuguru

    The “auction” type posts are also not being picked up by the BuddyPress activity stream.

    You’ll have to code that yourself, BP only does the post post type.

    But isn’t my code wrong somehow?

    If the post type registered (the parameter passed to the register_post_type function) is auctions, then your code is correct. Search the plugin or theme for the register function to get the post type name.

    justbishop

    @justbishop

    Oh, I’ve been messing with the plugin that creates the custom post type for a while. It is definitely “auctions”.

    Plugin Author Ron Rennick

    @wpmuguru

    Try

    function my_swt_post_type_filter( $auction ) {
    $auction['auctions'] = true;
    return $auction;
    }
    
    add_filter( 'sitewide_tags_allowed_post_types', 'my_swt_post_type_filter' );

    justbishop

    @justbishop

    OK, weird…that code causes the test “auction” post from the child site show up in my query on the main site (it’s the photo of the 4 different yarns under the heading “fresh”):

    http://www.riotcart.com

    But it’s not showing up under posts or the custom post type on my main site’s admin dashboard, or in any of the search screens.

    At least that pushed me forward a bit, thank you Ron 🙂

    justbishop

    @justbishop

    P.S. Here is the query that powers the “fresh” area on the index page (a child site’s post being displayed on the main site is conditional on NOT being in category #1, NOT having 2 certain tags, and having a value for the “thumbnail” custom field…aside from the “auction” post types not being displayed on search pages, this has all worked wonderfully for a while now):

    $args=array(
      'tag__not_in' => array($term->term_id, $term2->term_id),
      'category' => '-1',
      'post_type' => array( 'post', 'auctions' ),
      'post_status' => 'publish',
      'numberposts' => 8,
      'meta_key' => 'thumbnail',
      'caller_get_posts'=> 1,
    );

    And here is the one I have on my search.php:

    $args=array(
            'tag__not_in' => array($term->term_id, $term2->term_id),
            'category' => '-1',
      	'post_type' => array( 'post', 'auctions' ),
            'post_status' => 'publish',
            'caller_get_posts'=> 1,
            'meta_key' => 'thumbnail'
    );

    Any idea why the “auction” posts aren’t showing up in searches?

    Plugin Author Ron Rennick

    @wpmuguru

    I wouldn’t know without doing some testing. It’s not related to SWT though now that the post is getting there. It may be due to the same reason that the post isn’t showing in the CPT post listing in the admin area.

    Hey Ron-

    Andrea jumped in for support here but I thought that posting the question in this thread might be helpful as well.

    I’ve tested Sitewide Tags twice and it is not pulling in CPTs. This thread has been helpful but I seem to be missing a step someplace.

    The following is in the theme functions.php for the site that has the CPT:

    function my_swt_post_type_filter( $artifact ) {
    $artifact['artifacts'] = true;
    return $artifact;
    }
    
    add_filter( 'sitewide_tags_allowed_post_types', 'my_swt_post_type_filter' );

    SWT is setup to post to another subsite, not the main site. WP is 3.3.1. SWT is 0.4.1.1

    Plugin Author Ron Rennick

    @wpmuguru

    Is the CPT registered on the tags blog? If not, SWT will pull them but you won’t be able to see them.

    It is registered and, on the backed, it is populating properly. But on the front-end it is still not showing, just posts.

    I’m assuming I need to modify the loop of the Swt blog?

    Plugin Author Ron Rennick

    @wpmuguru

    I’m assuming I need to modify the loop of the Swt blog?

    Yes. If they show on the loop on the source blog then the code for modifying the loop is in the theme on the source blog. The default WP loop does not include CPTs.

    Thanks. Will do!

    I added this code on my child theme’s function.php

    function my_swt_post_type_filter( $hotels ) {
    	$hotels['hotel'] = true;
    	return $hotels;
    }
    
    add_filter( 'sitewide_tags_allowed_post_types', 'my_swt_post_type_filter' );

    It causes a white screen but it does transfer the custom post type to the main blog. Anyone who could help?

Viewing 15 replies - 1 through 15 (of 40 total)
  • The topic ‘[Resolved] [Plugin: WordPress MU Sitewide Tags Pages] Grabbing Custom Post Type Posts’ is closed to new replies.
Skip to toolbar