Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

get_posts and special characters WordPress

i need a get_posts() query with an array. I have problems to use the meta_value with a special char like küste (german ü) i try to use var's with htmlentities() with no luck. Any idea ?

$arg = array(
'post_type' => 'news',
'numberposts' => -1,
'post_status' => 'publish',
'post_parent' => null,
'order' => 'DESC',
'orderby' => 'post_date',
'meta_value' => 'küste', //<-- no results

Answers (3)


Denzel Chia answers:


Have you tried using html character entities to replace the ü?

Try using this instead, k&uuml;ste


Peter Brain comments:

yes but get no result.

i try

$value = htmlentities(esc_textarea ('küste'));
$arg = array( 'meta_value' => $value );

i can echo the ü but get no results.

Everything is utf-8 and the db value is ü but still no result.


Julian Lannigan answers:

I have tested your argument array on my sandbox site, and it seems to work just fine with the special letter.
[[LINK href=""]][[/LINK]]

Your positive one "news" has a custom field that equals "küste" exactly, right?

Peter Brain comments:

there is definetly a custom field with "küste", when i change the value to kuste erverything is fine.

Peter Brain comments:

is it possible to use wildcards in the get_post () function ?

for e.g. meta_value =>'k%ste'

Julian Lannigan comments:

I don't think it is. Given if its a char comparison it usually is wrapped in %s. "%küste%"

What version of WP are you using? If it's 3.1 you could try to use the meta_query option instead of the meta_value. Not sure exactly if that will work, but it's worth a try. [[LINK href=""]]see here[[/LINK]]


David Navarrete answers:

find the value on the table wp_postmeta and see how save the data