Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
 function rpm_pre_get_post($query){
       if($query->is_main_query()){
            $query->set('meta_key', 'parent-project');
            $query->set('meta_value', 'Metro-E');
        }
}
add_action( 'pre_get_posts', 'rpm_pre_get_post', 9999 );

That should effectively pull back all posts that have the key 'parent-project' set to 'Metro-E' correct?

below is what I get spit out when trying to debug

WP_Query Object
(
    [query_vars] => Array
        (
            [post_type] => rfd_job
            [posts_per_page] => 20
            [error] => 
            [m] => 0
            [p] => 0
            [post_parent] => 
            [subpost] => 
            [subpost_id] => 
            [attachment] => 
            [attachment_id] => 0
            [name] => 
            [static] => 
            [pagename] => 
            [page_id] => 0
            [second] => 
            [minute] => 
            [hour] => 
            [day] => 0
            [monthnum] => 0
            [year] => 0
            [w] => 0
            [category_name] => 
            [tag] => 
            [cat] => 
            [tag_id] => 
            [author_name] => 
            [feed] => 
            [tb] => 
            [paged] => 0
            [comments_popup] => 
            [meta_key] => parent-project
            [meta_value] => Metro-E
            [preview] => 
            [s] => 
            [sentence] => 
            [fields] => 
            [menu_order] => 
            [category__in] => Array
                (
                )

            [category__not_in] => Array
                (
                )

            [category__and] => Array
                (
                )

            [post__in] => Array
                (
                )

            [post__not_in] => Array
                (
                )

            [tag__in] => Array
                (
                )

            [tag__not_in] => Array
                (
                )

            [tag__and] => Array
                (
                )

            [tag_slug__in] => Array
                (
                )

            [tag_slug__and] => Array
                (
                )

            [post_parent__in] => Array
                (
                )

            [post_parent__not_in] => Array
                (
                )

        )

    [tax_query] => WP_Tax_Query Object
        (
            [queries] => Array
                (
                )

            [relation] => AND
        )

    [meta_query] => 
    [post_count] => 0
    [current_post] => -1
    [in_the_loop] => 
    [comment_count] => 0
    [current_comment] => -1
    [found_posts] => 0
    [max_num_pages] => 0
    [max_num_comment_pages] => 0
    [is_single] => 
    [is_preview] => 
    [is_page] => 
    [is_archive] => 
    [is_date] => 
    [is_year] => 
    [is_month] => 
    [is_day] => 
    [is_time] => 
    [is_author] => 
    [is_category] => 
    [is_tag] => 
    [is_tax] => 
    [is_search] => 
    [is_feed] => 
    [is_comment_feed] => 
    [is_trackback] => 
    [is_home] => 
    [is_404] => 
    [is_comments_popup] => 
    [is_paged] => 
    [is_admin] => 1
    [is_attachment] => 
    [is_singular] => 
    [is_robots] => 
    [is_posts_page] => 
    [is_post_type_archive] => 
    [query_vars_hash] => cf1479fdf40685bcc6b8eb6b842a2f6b
    [query_vars_changed] => 
    [thumbnails_cached] => 
    [query] => Array
        (
            [post_type] => rfd_job
            [posts_per_page] => 20
        )
share|improve this question
2  
That is really not a very descriptive title. –  s_ha_dum Oct 21 '13 at 22:33
    
Where/how did you dump that WP_Query object? –  s_ha_dum Oct 21 '13 at 22:35
    
I tested your code and get a different output. I see a properly constructed WP_Meta_Query object. There is something broken on your site or perhaps something interfering but I am not sure what. –  s_ha_dum Oct 22 '13 at 0:47
    
hmmm.. something must be broken with a query somewhere... this program is over 15,000 lines of code long... happy hunting I will go. shit. well the output to the front end does not work properly.. I have had no real use for it... any ideas? all searches construct the query correctly in the admin as well. –  Robert Ruby II Oct 22 '13 at 18:35
    
hmmm.. something must be broken with a query somewhere... this program is over 15,000 lines of code long... happy hunting I will go. shit. well the output to the front end does not work properly.. I have had no real use for it... any ideas? all searches construct the query correctly in the admin as well. When I have some more time I'll update this question with w/e I find. I am using wordpress in a very unique manner to create a management system for my utility engineering company. still in pre beta use i would guess.---- the edit comment time limit crap is well crap –  Robert Ruby II Oct 22 '13 at 18:43
add comment

closed as off-topic by toscho Dec 5 '13 at 1:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

Perhaps you should try this:

function rpm_pre_get_post($query){
   if($query->is_main_query()){
        $query->set('meta_query', array(
               array(
                   'key' => 'parent-project',
                   'value' => 'Metro-E'
               )
           )
        );
    }
}
add_action( 'pre_get_posts', 'rpm_pre_get_post', 9999 );
share|improve this answer
add comment
up vote -1 down vote accepted

There was an issue caused by so search filtering I was doing. I removed that code and everything was good.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.