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)

2011-05-23

Denzel Chia answers:

Hi,

Have you tried using html character entities to replace the ü?
http://htmlhelp.com/reference/html40/entities/latin1.html

Try using this instead, k&uuml;ste

Thanks.
Denzel


Peter Brain comments:

yes but get no result.

i try

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


i can echo the ü but get no results.

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

2011-05-23

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="http://testwp.jlconsulting.co/"]]http://testwp.jlconsulting.co/[[/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="http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters"]]see here[[/LINK]]

2011-05-25

David Navarrete answers:

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