WordPress.org

Support

Support » Plugins and Hacks » Hacks » args provided to WP_Query returning zero results?

args provided to WP_Query returning zero results?

  • Hi all,

    I’m building a plugin that involves domain mapping. That’s really neither here nor there for my problem, but there ya have it.

    I am attempting to validate a value against the database by using WP_Query to perform a meta_key/meta_value query. The function wrapping this validation is attached to the init hook.

    Here is the code: http://pastebin.com/5i4AepzX

    None of the $args in the InnerbotPartnerPagesFrontend::is_valid_partner() plugin method return the desired result. I’m attempting to find any posts of the type “certified-partner” that have a meta_key “ibpp_domain_to_map” with a corresponding meta_value $domain_name…

    The only time I get ANY results what so ever and trigger the wp_die method you see on line 41 is when I use the $args that I left uncommented on line 29. But that still returns irrelevant data.

    Even trying to run a query that is set to only return “certified-partner” post types is returning 0 results even though there are four of this post_type in the db.

    Any help is greatly appreciated!

Viewing 1 replies (of 1 total)
  • So, after some more research, I realized this could be caused by my CPT having publicly_queryable, and exclude_from_search set to FALSE. So I removed all arguments for the post type except the labels and supported fields…

    This still hasn’t fixed the problem. Here is a quick snippet of the current Custom Post Type definition:

    public function action_init_register_post_type() {
    		global $wp_rewrite;
    
    		register_post_type( $this->post_type, array(
    			'labels' => array(
    				'menu_name'          => __( 'Certified Partners',        'ibpartnerpages' ),
    				'name'               => __( 'Certified Partners',        'ibpartnerpages' ),
    				'singular_name'      => __( 'Certified Partner',         'ibpartnerpages' ),
    				'all_items'          => __( 'All Certified Partners',    'ibpartnerpages' ),
    				'add_new'            => __( 'New Certified Partner',     'ibpartnerpages' ),
    				'add_new_item'       => __( 'New Certified Partner',     'ibpartnerpages' ),
    				'edit_item'          => __( 'Edit Certified Partner',    'ibpartnerpages' ),
    				'new_item'           => __( 'New Certified Partner',     'ibpartnerpages' ),
    				'view_item'          => __( 'View Partner Landing Page', 'ibpartnerpages' ),
    				'search_items'       => __( 'Search Partners',           'ibpartnerpages' ),
    				'not_found'          => __( 'No Partners found',         'ibpartnerpages' ),
    				'not_found_in_trash' => __( 'No Partners found in trash','ibpartnerpages' ),
    				),
    			'menu_icon' => plugins_url('img/certified-partner.png', __FILE__),
    			'supports'      => array( 'revisions' ),
    		) );
    
    		maybe_flush_rewrite_rules( $this->post_type );
    
    	}

    Still working on a solution here… Anyone with some insight?

    I’m going to try switching over to manual $wpdb queries, as that seems the only other viable option to get this project out the door on time.

Viewing 1 replies (of 1 total)
  • The topic ‘args provided to WP_Query returning zero results?’ is closed to new replies.
Skip to toolbar