Support » Networking WordPress » Query Custom Posts based on Custom Taxonomy SITE WIDE

  • Resolved thecorkboard

    (@thecorkboard)


    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]

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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.

    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.

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

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

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

    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.

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

    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?

    white screen = php error. 🙂 Check your error logs.

    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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Query Custom Posts based on Custom Taxonomy SITE WIDE’ is closed to new replies.