11 reputation
6
bio website
location
age
visits member for 11 months
seen Sep 20 '13 at 2:49

Feb
24
awarded  Popular Question
May
3
awarded  Scholar
May
3
accepted $wpdb returns no results with SELECT query on custom post type, works on default post type
May
1
awarded  Teacher
May
1
answered $wpdb returns no results with SELECT query on custom post type, works on default post type
May
1
revised $wpdb returns no results with SELECT query on custom post type, works on default post type
added more info
May
1
comment Plugin works for default post types, but not for custom
I posted the question here in a more broad, conceptual sense, simply because all of the discussion on the other post is wrapped up in the code, and there's nothing wrong with the code if it works for default post types, and it does. It may not be the best written code, but it does work on a default post type.
May
1
asked Plugin works for default post types, but not for custom
May
1
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
The var_dump ($query); returns NULL. It actually wasn't returning anything before because the code for that was after the $wpdb->print_error(); code.
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
It's a custom table with only two fields--quilt_id and quilt_guid. For each post (whether default post type or quilt post type) a random number is generated and inserted into the table as the quilt_id and the post_guid is inserted as the quilt_guid. All I'm trying to do here is retrieve the quilt_id that's associated with the post from the table.
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
Yes, the quilt_id is in the table, and as I said, this all works from the same exact table (the table is not post-type specific) if the post type in the plugin is set to "post" instead of "quilt".
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
If I use var_dump( $query ); it returns SELECT * FROM wp_qrcodeitdata WHERE qrci_guid = "http://catsquiltshow.quiltshow-cat-alog.com/?post_type=quilt&p=49". Is that how I would get everything in the query object? (and sorry if I didn't get that right, I'm still on the learning curve of all this!)
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
There isn't really another value I can search on. I need to use an absolutely unique identifier for the post that isn't dynamically generated (like the permalink), and the guid is it. Also, I'm using if (isset($_quilt_id)) { //do stuff with $_quilt_id } as a check, and I can certainly change it to what you've suggested, but not quickly. The queries do match, and there is a record in the table being returned in phpmyadmin, so I still can't see what the problem might be.
Apr
30
awarded  Commentator
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
This queries a custom table that the plugin creates, yes. As for var dumping, isn't that what this does "var_dump( $wpdb->last_query );"? It's already in the code, and it's returning SELECT * FROM wp_customtable WHERE qrci_guid = "somewebsite/post_type=quilt&p=49"
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
I've edited the query that returns the correct result from the database directly. I don't know why the ">" was in there, but it's really not when I run the query in phpmyadmin. I'll look at the rest of your response separately. :-)
Apr
30
revised $wpdb returns no results with SELECT query on custom post type, works on default post type
edited query to remove incorrect character
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
$_quilt_id = $query->quilt_id; is line 126.
Apr
30
comment $wpdb returns no results with SELECT query on custom post type, works on default post type
The "somewebsite" bit in the OP is really a true URL in the errors, but it wouldn't let me post the actual URLs until I have 10 reputation here. :-(
Apr
30
asked $wpdb returns no results with SELECT query on custom post type, works on default post type