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 &#8211;

in post title i'm add: This - is - post in html source: var availableZtour = ["This &#8211; is &#8211; 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.

Similar questions

how to use echo to echo div if condition within that div is met
I have a simple php script that I am using to display social icons if user has provided their social network username in the fields of their user account in wordpress. Problem is that all of the network icons are being displayed even if the networks username was not provided. I clearly understand the reason why it is happening since all of the divs...
PHP: Echo IMG src= php echo
I have the following code working in another document but now i took to next expression: but seems like the parth isnt correctly implemented, tried diferent things i found on the web but couldnt manage to find a solution... EDIT: The image isnt loading when i use the second code.
I am trying to echo an alert when input field was empty, but it alway echo alert
I am using wordpress login. I am trying to call a function when the login or password input was empty. I am trying the following code, no matter I enter something into the input or nothing, it always echos alert, why? I know inside input, value="", means nothing before I enter anything, even if I enter something, on the console, I still see the val...
How do I rewrite an PHP echo inside a PHP echo?
I want to place this code: inside of this code: where it says [email protected] Can someone write this so I can understand?
CSS dosen't work with my PHP code (echo/no echo)
I am trying to convert an html theme to work with Wordpress and I got stuck on a rather simple code and I don't understand why. Why does this code: not work the same as this (CSS doesn't work)?
echo $variable in another echo
I'm stacked. Can't get it, how put this variable: This var contain link, that should be In this code:

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.