Javascript / WP while loop issue…
-
Deep breath…
I have the following snippet of JS code…
var fcontent=new Array(); begintag='<div class="two">'; //set opening tag, such as font declarations </script> <script type="text/javascript"> <?php query_posts('showposts=1&cat=5'); ?><?php while (have_posts()) : the_post(); ?> fcontent[0]='<img src="<?php $supporting_image=get_post_meta( $post->ID, 'thumbnail', true ); if (''!=$supporting_image) { echo $supporting_image; } ?>" width="115" height="77" alt="" class="newspic" /><div class="calendarbit"><span class="day"><?php the_time('j'); ?></span><span class="month"><?php the_time('M'); ?></span></div><p class="titlebit"><?php the_title('<span style="font-weight:bold"><a href="/category/news">', '</a></span>'); ?><a href="/category/news"><img src="/images/news_icon.jpg" alt="" width="9" height="9" /></a></p>' <?php endwhile;?> closetag='</div>';
which works fine. It gets one post from the category, then stores all the data in the fcontent[0] element.
But I wonder how I can select 3 Posts from my Query and then create a ‘fcontent’ array element for each.
So you’d have:
fcontent[0] = ‘news item 1 info’
fcontent[1] = ‘news item 2 info’
fcontent[2] = ‘news item 3 info’Is it easy to do this?
Many thanks for any assistance.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Javascript / WP while loop issue…’ is closed to new replies.