Customize Search Meta Query ? Challenge for real WordPress Guru
-
Hi guys,
I’ve been in a stumbling block for long. Now I would like to ask expert like you that.I would like to customize my Search to search only in a specific meta_key and meta_value and return posts or post->ID.
Here what my dbase wp_postmeta looks like.
meta_id post_id meta_key meta_value 1 5 numero_dispo 10, 20, 63 2 8 numero_dispo 25, 42, 10 3 1 numero_dispo 15, 54, 48 4 3 numero_dispo 20, 78, 27
I would to have the post->ID for i.e that search: 20 (space) 10 (space) 63 or 20+10+63
And would like to my search to return where it finds all the number and where it finds for each number.
In this case:
post #5 (first)
post # 8
post# 3.The closer I have gone, is that:
if ( $_GET["s"]!='Search') { $key_1_value=$_GET["s"]; $exploded = explode(' ', $key_1_value); ksort($exploded, SORT_NUMERIC); foreach ($exploded as $key => $val) { $arg =array('numberposts' => $number, 'post_type'=>$post_type, 'meta_query' => array( array( 'key' => 'numero_dispo', 'value' => $val, 'compare' => 'LIKE', ) ));
But it wasn’t good:
#1 That checks value one by one not in group.
#2 He returns post ID for each time it finds the a value in it.
i.e: Post #5 will display 3 times.Any help please.
- The topic ‘Customize Search Meta Query ? Challenge for real WordPress Guru’ is closed to new replies.