[wp-hackers] Custom search, how ?
Lox
lox.dev at knc.nc
Wed Aug 18 12:19:09 UTC 2010
>
> You should join using the post ID directly.
>
I can't actually because, the separated table is "read only" for me. It is a
separated excel database regularly dumped into mysql.
2010/8/18 Lox <lox.dev at knc.nc>
>
> Thanks figured it myself. It works with WP_Query, I call it with a custom
> query var that I can check for in posts_join (is the way to do?)
>
> How can I JOIN with a custom table ON a custom meta field ?
I have found the thing and I have done some progress:
I have a custom post-type "training" and a custom table "wp_training_infos".
For each training post type, I have a drop down box to select the matching
record in the "wp_training_infos" table. (I have no other way to link them
other than manually).
So each post_type object (like the one returned by get_post() ) is now
extended with the matching data from wp_training_infos. (I use posts_join
and posts_where when post_type matches "training")
Doing so, it is ok, I can do:
$wp_query('post_type=training&field_from_wp_training_info=value)
>
Witch is nice. But, now, I need to select training posts for an other meta,
withc would be:
$wp_query('post_type=training&field_from_wp_training_info=value&meta_key=my_meta&meta_value=the_value)
Witch fails because I already use a meta to join with my custom table.....
(1) here is my code http://paste2.org/p/954990
--
Lox
lox.dev at knc.nc
More information about the wp-hackers
mailing list