Last time i had some problem in my code, by now i have fixed the problem but there is one more problem exixting.
Here in my code, the main <div>
automatically loops 5 times showing the same list of elements 5 timee. I am unable to find out what has caused the loop. On inspecting the element, i came to know that the main loop i.e. <div class="row-fluid">
loops for 5 times. Where is the problem and how can i solve it?
Really need help.
Thank u in advance.
<?php if ($cat == 2900) { ?>
<div class="row-fluid">
<div class="span12 featured-block">
<?php $block1Featured= new WP_Query( 'cat=2900' );
if ( $block1Featured->have_posts() ) : ?>
<?php while($block1Featured->have_posts()): $block1Featured->the_post(); ?>
<div class="span6 ">
<a class="featured_image" href="<?php the_permalink();?> "target="_blank">
<?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) {
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'large');
$image_url = $image_url[0];
if(!@getimagesize($image_url)){
$image_url = "/wp-content/uploads/2014/02/logo2.jpg";
}
$blogurl = get_bloginfo('url');
$image_url = str_replace($blogurl, '', $image_url);
?>
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo ($image_url); ?>&w=390&h=216&zc=1&q=100" alt="<?php echo the_title(); ?>" />
<?php }else{ ?>
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo "http://www.nepaljapan.com/wp-content/uploads/2014/02/logo2.jpg"; ?>&w=390&h=216&zc=1&q=100" alt="<?php echo the_title(); ?>" />
<?php }?>
</a>
<a href="<?php the_permalink();?>" target="_blank">
<h2><?php the_title(); ?></h2></a>
<p><?php echo excerpt(37); ?> </p>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
</div>
<?php } ?>
<?php }else{ ?>
//else contents
<?php } ?>
Try this