Results 1 to 4 of 4
-
20th Oct 2011, 08:01 PM #1OPMember
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>
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>
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
-
21st Oct 2011, 08:26 PM #2Respected 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;
-
22nd Oct 2011, 11:39 AM #3OPMember
Thanks! Gave me enough to work on
-
22nd Oct 2011, 02:03 PM #4Respected Member
You are welcome.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[PHP] Need help to loop true the results
By AndroidApps in forum Web Development AreaReplies: 6Last Post: 5th Feb 2012, 09:56 AM -
Php Loop Prob
By Chris2k in forum Web Development AreaReplies: 1Last Post: 16th Jan 2012, 02:00 PM -
First Time On A Motorcycle FAIL
By Daniel in forum General DiscussionReplies: 1Last Post: 30th Oct 2010, 08:35 PM -
How Much Time Does It Take To Create New Nameservers and having them work Properly?
By dxgamers in forum Webmaster DiscussionReplies: 3Last Post: 16th Sep 2010, 05:42 AM -
Redirect loop?!?!
By GeeZus in forum Technical Help Desk SupportReplies: 4Last Post: 9th Jun 2009, 04:36 AM
themaManager - edit and manage...
Version 4.17 released. Open older version (or...