wordpress javascript echo Numeric
My script :
<script>
$(function() {
var availableZtour = [<?php query_posts('category_name=ztour&showposts=5&orderby=date'); if (have_posts()) { while (have_posts()) { the_post(); ?>"<?php the_title(); ?>",<?php }} wp_reset_query(); ?>];
$( "#ztour" ).autocomplete({
source: availableZtour
});
If i'm add – weird hyphen => script echo – weird hyphen
but: i'm add
-
normal hyphen => script echo
–
in post title i'm add:
This - is - post
in html source:
var availableZtour = ["This – is – post",]
How? when i'm add
-
normal hyphen => script echo
-
Thanks
Solutions
Inside WordPress, a couple functions are registered to handle the
the_title
hook automatically. One of them is
wptexturize()
, which converts quotes to "smart quotes" and turns some
special characters
into their respective HTML entities.
You should be able to remove it with something like
remove_filter( 'the_title', 'wptexturize' )
before your loop. Otherwise, you could access
$post->post_title
directly, but then you're responsible for sanitizing it yourself.