How can I restrict the Post Indexer to certain categories on my network of sites? I have a category

Wordpress Version 3.5.2
Post Indexer 3.0.4

All my network sites have a "Featured" category of posts. I ONLY want to get that category indexed so I can display them on the front page of my main site.

  • Alexander
    • DEV MAN’s Mascot

    Hi James,

    What are you using to display the posts? It's possible to provide a category parameter to the network query, but only with some custom coding. Are you using a particular plugin to show the posts, or are you using the network query function?

    Best regards

  • Alexander
    • DEV MAN’s Mascot

    In recent-posts.php on line 69 you'll see the query.

    $network_query = network_query_posts( array( 'post_type' => $posttype, 'posts_per_page' => $tmp_number ));

    Try changing this to:

    $network_query = network_query_posts( array( 'post_type' => $posttype, 'posts_per_page' => $tmp_number, 'cat' => '5' ));

    Where 5 is the ID of the category you're looking for. You will need to have categories created with the same ID for this to work.

    Best regards

  • waynemorris
    • Site Builder, Child of Zeus

    Hi Alexander,

    I have done what you suggest above but it does not work for me, I have made sure I use the right ID.

    May I ask does my main site also need to have the category, or just my subsites as all my subsites have a cateogory with the ID 6, but my main site does not?

    Thanks

    Wayne

  • Alexander
    • DEV MAN’s Mascot

    Hi @waynemorris,

    The network query API would suggest we can do this, but I've tried it and I'm unable to get this working myself, so I'm not quite sure how to answer your question.

    I will however check with the plugin developers to see if they have any ideas here.

    Best regards,

  • Town of Sudbury
    • New Recruit

    Alexander,

    We have been doing some major modding to multisite for our new site. I discovered this bug in Post Indexer a few months ago and the less-than-perfect patch I have is to sync all the category tables together across the entire network because the category IDs get screwed up if they are different for each site.

    There are several ways to do this, but right now I'm just mirroring all wp_#_terms, and wp_#_term_taxonomy tables off of the site 1 tables (IDs and all) and preventing subsites from creating terms and taxonomies. (I think you can also modify $wpdb->terms and $wpdb->term_taxonomy)

    If I remember correctly the term ids in wp_network_terms are mismatching with the ids in wp_network_term_relationships so when I did network_query_posts((array 'category_name' => 'Front Page News')); it would return posts that were never in that category.

    It would be great if this bug could be fixed at some point so that we can restore regular operation of taxonomies.

    Thanks,

    Eddie Hurtig
    Web Developer

  • Alexander
    • DEV MAN’s Mascot

    Hey @Town of Sudbury,

    Would you mind opening up a new thread for this? Then we can test and followup as needed. That way we don't miss anything, and can be courteous to the users above. This way they won't be receiving post notifications from our conversation - long after the topic was originally raised.

    It's also easier for us to keep track of newer threads.

    You can start a new topic here: https://premium.wpmudev.org/qanda

    Thanks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.