Scrolling text Javascript and php/wordpress data HELP!!
-
I am producing a custom feature on the homepage of a wordpress site. I am producing 3 vertical scrolls on the same page and have found a java script on Dynamic drive that fulfils my needs. See https://www.dynamicdrive.com/dynamicindex2/crosstick.htm
The scrollers display different posts on different days. I.e Monday post 1, tuesday post 2 and so on.
The basic version of the javascript for the content for the slider is:
var pausecontent=new Array()
pausecontent[0]=’JavaScript Kit
Comprehensive JavaScript tutorials and over 400+ free scripts!’
pausecontent[1]=’Coding Forums
Web coding and development forums.’
pausecontent[2]=’CSS Drive
Categorized CSS gallery and examples.’But where the script puts the scroller content, I need to make the loop and output the_content from wordpress. (For now I have set this up to show certain posts, but it will be all posts from a specific category) So I need to create a unique number for the array i.e pausecontent[**here**] so I have called the post id. and for the content I have called the content. Here i smy code:
<script type=”text/javascript”>
var pausecontent3=new Array()
<?php// FIND POST ACCORDING TO DAY
switch(date(‘N’)) {
case 1: ?>
<?php query_posts(‘p=69’); ?>
<?php break;
case 2: ?>
<?php query_posts(‘p=71’); ?>
<?php break;
case 3: ?>
<?php query_posts(‘p=73’); ?>
<?php break;
case 4: ?>
<?php query_posts(‘p=75’); ?>
<?php break;
case 5: ?>
<?php query_posts(‘p=77’); ?>
<?php break;
case 6: ?>
<?php query_posts(‘p=79’); ?>
<?php break;
case 7: ?>
<?php query_posts(‘p=81’); ?>
<?php break;
default:
}// the Loop
while (have_posts()) : the_post(); ?>
pausecontent3[<?php $meta_desc = get_post_meta(the_ID()); echo $meta_desc; ?>]='<?php the_content(); ?>’
<?php endwhile; ?>
//new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)
new pausescroller(pausecontent3, “pscroller3”, “someclass”, 2000)
</script>
I keep getting the ‘undefined’ notice when I run the script. I check over the source from the browser and it displays correctly in the source, but it doent run correctly and seems that Javascript is not recognising the PHP inputs.
Can anyone shed any light on this at all or have any suggestions?
Thanks
- The topic ‘Scrolling text Javascript and php/wordpress data HELP!!’ is closed to new replies.