WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Sitewide Tags Pages
[resolved] Grabbing Custom Post Type Posts (41 posts)

  1. justbishop
    Member
    Posted 2 years ago #

    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/

  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    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?

  3. justbishop
    Member
    Posted 2 years ago #

    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?

  4. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    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.

  5. justbishop
    Member
    Posted 2 years ago #

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

  6. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    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' );
  7. justbishop
    Member
    Posted 2 years ago #

    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 :)

  8. justbishop
    Member
    Posted 2 years ago #

    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?

  9. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    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.

  10. thecorkboard
    Member
    Posted 2 years ago #

    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

  11. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

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

  12. thecorkboard
    Member
    Posted 2 years ago #

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

  13. thecorkboard
    Member
    Posted 2 years ago #

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

  14. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    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.

  15. thecorkboard
    Member
    Posted 2 years ago #

    Thanks. Will do!

  16. archersify
    Member
    Posted 2 years ago #

    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?

  17. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    Make sure my_swt_post_type_filter is not a duplicate function name.

  18. archersify
    Member
    Posted 2 years ago #

    Hello Ron,

    Thanks for the reply. I changed my_swt_post_type_filter to my_swt_hotel_type_filter just to make sure it has no duplicate. Still no luck.

    Im using Custom Post Type UI and Advanced Custom Fields.

    Regards,
    Archer

  19. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    I've heard of the plugin but haven't used it. You may have to manually register the post type in your theme functions file or a plugin.

  20. archersify
    Member
    Posted 2 years ago #

    Hello Ron,

    I will try to have the post types manually registered in my function. I will let you know later if that worked.

    Thanks,
    Mark

  21. archersify
    Member
    Posted 2 years ago #

    Ron,

    Ive tried installing the custom post types manual but i still get the whitescreen after adding a new post for the custom post type.

    Hope you can shed some light.

    Thanks,
    Mark

  22. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    Whenever you have a white screen there should be an error recorded in your error logs. This is one where you'll have to track down the offending plugin/theme.

  23. archersify
    Member
    Posted 2 years ago #

    I am not getting any error on the error_log located on my root directory.

    Any other possible solution or source of the problem?

    These are the things ive tried so far.
    1. Manual creation of custom post types instead of using custom post types UI

    2. Custom post types are registered on both the main site and the sub-site (source site).

  24. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    Your web account control panel should have an error log that you can look at.

    When you are running a network don't expect to find anything in the error_log files. Error logging to those files is disabled when the network is enabled.

  25. archersify
    Member
    Posted 2 years ago #

    Hello Ron,

    I was able to make this to work. Thanks for taking time replying to me. The problem was with Advanced custom fields plugin. I have to remove it and installed wordpress types. :)

    Best Regards,
    Mark

  26. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    Thanks for letting me know :)

  27. archersify
    Member
    Posted 2 years ago #

    Ron,

    Though i was successful on getting the custom post type displayed on my main site, i am having an issue on its featured image. Its seems that the featured image from the custom post type is not included in the transfer? It works on the regular posts though.

    Regards,
    Mark

  28. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    I wasn't aware there was any distinction of the featured image between regular posts and CPTs.

    I'll put that on the list to look at after we put out the next version. I have one last thing to track down with the dev version.

  29. archersify
    Member
    Posted 2 years ago #

    Hi Ron,

    It would be great if you could include that feature. :) I will be waiting for this as this is a crucial part of my development.

    Best Regards,
    Mark

  30. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 2 years ago #

    If you check my profile page http://profiles.wordpress.org/users/wpmuguru/profile/public/ you'll see I have almost 30 plugins there. If I spend an hour a day across those plugins it works out to about an hour a month per plugin.

    If you really need the feature for your project then look at hiring a developer to see if they can track the issue down. (I work full time and am not taking any projects.)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic