WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Query Custom Posts based on Custom Taxonomy SITE WIDE (11 posts)

  1. thecorkboard
    Member
    Posted 2 years ago #

    Hello-

    I'm trying to grab all published posts from custom post type "artifacts" in custom taxonomy "slis_goals" that are published across the entire site (site wide). I can grab artifacts from a single site using the code below but when the same template is used on the parent (main, ID=1) site, it doesn't pull in anything. Documentation on this sort of thing is weak in the codex and online, so I'm not exactly sure how to query the database to look in all _posts tables across all sites. Thanks for any ideas you may have.

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. I'm not exactly sure how to query the database to look in all _posts tables across all sites.

    with a massive sql statement that would be horribly inefficient.

    use something like the sitewide tags plugin to grab them all. y, it does pick up custom posts.

  3. thecorkboard
    Member
    Posted 2 years ago #

    Andrea-
    I've tested this twice with Sitewide Tags and it is not pulling in CPTs. For reference, I've been trying to glean know-how from Ron here:

    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
    I feel like I'm following everything to a "T" without much luck.

  4. thecorkboard
    Member
    Posted 2 years ago #

    Also, I'm reading in other thread that SWT supports post formats, not necessarily custom post types....

  5. have you got a theme on that site that shows the CPTs?

  6. thecorkboard
    Member
    Posted 2 years ago #

    Yea, just the single-artifacts.php template at this point as that's all I need for a demonstration tomorrow.

  7. If you login to the tags blog, do you see a spot to make a brand new CPT?

    If not, that;s the issue. THe CPT also have to be active on that blog.

  8. thecorkboard
    Member
    Posted 2 years ago #

    All's working now. Just need to modify the loop. Thanks!

  9. 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?

  10. white screen = php error. :) Check your error logs.

  11. archersify
    Member
    Posted 2 years ago #

    Hello Andrea_r,

    [20-Jan-2012 00:45:22] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2ts.lin' - /usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2ts.lin: undefined symbol: executor_globals_id in Unknown on line 0

    Here's the error i am getting. The whitescreen only appears when the filter code works. :) If i commented out this code, everything works at my backend. Im using genesis theme as the framework.

    boracay.ph is the site.

Topic Closed

This topic has been closed to new replies.

About this Topic