Using WP_Query within an mu-plugin

I figured it out. I moved the reference to WP Alchemy within a function that fires after init. Everything now works great and I can use WP_Query within the setup files. Here’s a code reference: // WP Alchemy Setup function jd_setup_wp_alchemy() { include_once WPMU_PLUGIN_DIR . ‘/jonathanwold/metaboxes/setup.php’; include_once WPMU_PLUGIN_DIR . ‘/jonathanwold/metaboxes/cpt-spec.php’; } add_action(‘init’, ‘jd_setup_wp_alchemy’);

Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?

Thanks guys. I think I may have found a solution. What I did: On taxonomy-types.php, get all Items for that type using WP_QUERY. Loop through them, use get_the_terms() to get taxonomy Model for each Item Still in the loop: use PHP’s in_array() function and a $model_ids array for unique Model checking Still in the loop: … Read more

Modify WP Query post__in before have_posts()

I can see several possibilities for this one. First, I am not convinced that that you can’t use pre_get_posts though maybe you’d have to reorganize your code. You don’t have to wait for your theme template to use $_GET. Try: function tst() { // global $_GET; // sometimes necessary var_dump($_GET); } add_action(‘pre_get_posts’,’tst’); So I think … Read more

Custom loop with multiple taxonomy queries

Here’s a function to do a query with multiple taxonomies: function posts_search ($post_type,$taxonomies) { // $taxonomies should be an array (‘taxonomy’=>’term’, ‘taxonomy2’=>’term2’) foreach ($taxonomies as $key=>$value) { $args=array(‘post_type’=>$post_type,’post__in’=>$ids,$key=>$value); unset($ids); $ids=array(); foreach($posts=get_posts($args) as $post) { $ids[]=$post->ID; } if (empty($ids)) return false; } return $posts; } And here’s an example on how i used it in a … Read more

wp_query should show stickies first

Well for starters, the query arg showposts has been replaced by posts_per_page since WP v2.1 I don’t think any of your query args are being ignored (well, maybe save showposts; I haven’t checked to see if backwards compatibility support still exists for the arg). That said, I do not know what value your $top_row_posts variable … Read more