Trying to create a ForEach loop #fail every time

Status
Not open for further replies.

AndroidApps

Active Member
326
2010
4
0
Hi,

I'm not having any luck tonight.
I can't get the code below in a foreach loop:

Code:
    <div id="featured">
                <div class="scrollContainer">
                                        <?php
                                        add_filter('posts_fields', 'featured_fields');
                                        add_filter('posts_join', 'featured_join');
                                        add_filter('posts_where', 'featured_where_featured');
                    $featuredPosts = new WP_Query();
                    $featuredPosts->query('showposts=5');
                                        while ($featuredPosts->have_posts()) : $featuredPosts->the_post();
                    ?>
                    <div class="panel" id="post-featured-<?php the_ID(); ?>">
                        <div class="in-panel">
                                <a href="<?php the_permalink() ?>" title="<?php the_title_attribute('echo=1'); ?>"><img src="<?php bloginfo('url'); ?>/<?php echo get_post_meta(get_the_ID(), '_video_thumbnail',true)?>)"></a>
                                    <?php the_excerpt(); ?><br />
                        </div>
                    </div>
                    <?php
                                        endwhile;
                                        remove_filter('posts_where', 'featured_where_featured');
                                        ?>

                </div>
    </div>
The actual piece of code that needs to loop is:

Code:
                    <div class="panel" id="post-featured-<?php the_ID(); ?>">
                        <div class="in-panel">
                                <a href="<?php the_permalink()  ?>" title="<?php the_title_attribute('echo=1'); ?>"><img  src="<?php bloginfo('url'); ?>/<?php echo  get_post_meta(get_the_ID(),  '_video_thumbnail',true)?>)"></a>
                                    <?php the_excerpt(); ?><br />
                        </div>
                    </div>

My coding skills are pretty basic but I got to a point where the loop was ok but the php code could ot be executed.
Any help would be appreciated.
 
3 comments
I am guessing this is wp since I am not familiar with it but try this code:
PHP:
                    while  ($featuredPosts->have_posts()) : 
                                    $featuredPosts->the_post();
                                    echo '<div class="panel" id="post-featured-'.the_ID().'">
                                              <div class="in-panel"><a href="'.the_permalink().'" title="'.the_title_attribute('echo=1').'">
                                              <img src="'.bloginfo('url').'/'.get_post_meta(get_the_ID(), '_video_thumbnail',true).'"></a>'
                                            .the_excerpt().'<br /></div>
                                         </div>';
                    endwhile;
 
Status
Not open for further replies.
Back
Top