Activity Stream
48,167 MEMBERS
61890 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Member

    Default Trying to create a ForEach loop #fail every time

    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.
    AndroidApps Reviewed by AndroidApps on . Trying to create a ForEach loop #fail every time Hi, I'm not having any luck tonight. I can't get the code below in a foreach loop: <div id="featured"> <div class="scrollContainer"> <?php add_filter('posts_fields', 'featured_fields'); Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    I am guessing this is wp since I am not familiar with it but try this code:
    PHP Code: 
                        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; 

  4.     
    #3
    Member
    Thanks! Gave me enough to work on

  5.     
    #4
    Respected Member
    You are welcome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [PHP] Need help to loop true the results
    By AndroidApps in forum Web Development Area
    Replies: 6
    Last Post: 5th Feb 2012, 09:56 AM
  2. Php Loop Prob
    By Chris2k in forum Web Development Area
    Replies: 1
    Last Post: 16th Jan 2012, 02:00 PM
  3. First Time On A Motorcycle FAIL
    By Daniel in forum General Discussion
    Replies: 1
    Last Post: 30th Oct 2010, 08:35 PM
  4. Replies: 3
    Last Post: 16th Sep 2010, 05:42 AM
  5. Redirect loop?!?!
    By GeeZus in forum Technical Help Desk Support
    Replies: 4
    Last Post: 9th Jun 2009, 04:36 AM

Tags for this Thread

BE SOCIAL