How can I put WordPress post loop Codes in javascript?
function top_news() {
echo '<div class="news"></div>';
$query = get_posts(array(
'showposts' => 3,
'type' => 'topnews'
));
foreach ($query as $news) :
the_post($news);
endforeach;
?>
<script type="text/javascript">
$(function () {
$(".news").typed({
strings: ["here........."],
typeSpeed: 1,
showCursor: 0,
loop: 1
});
});
</script><?php
}