I am facing issue in debug mode with wordpress. In my featured slider getting error
Notice: Object of class WP_Query could not be converted to int in on line
I am using below code for my slider
<div id="<?php slider_class() //Theme function ?>" class="clearfix">
<!--[BEGIN: Slider wrapper]-->
<div id="slides-wrapper" <?php slider_wrapper_class() //Theme function ?>>
<!--[BEGIN: #Slides]-->
<div id="slides" class="<?php slides_class() //Theme function ?> clearfix">
<!--[BEGIN: Slides_container]-->
<div class="slides_container <?php slides_class() //Theme function ?>">
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query('showposts='.get_option('mp_slides_no').'&category_name='.get_option('mp_featured_cat').'');
for($i=1; $i<=$featuredPosts; $i++) { // second for() loop for post slides
while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); // loop for posts
?>
<?php if (get_option('mp_slides_content') === "content_s") { ?>
<!--[BEGIN: ALL SLIDES ++]-->
<div class="slide clearfix">
<!-- thumbnail start -->
<?php mp_thumb('featured-thumbnail','featured-slider-thumbnail','480'); //Theme function ?>
<!-- end of thumbnail -->
<div class="featured-excerpt">
<h2 class="title"><a href="<?php the_permalink(); ?>"><?php echo substr($post->post_title,0,50); // short title ?>...</a></h2>
<?php the_excerpt(); ?>
<br />
<a href="<?php the_permalink(); ?>" class="featured-readmore clearfix"><span>Read more</span><img src="<?php bloginfo('template_directory'); ?>/images/button-arrow.png" alt="readmore" width="24" height="24" /></a>
</div>
</div>
<!--[END: ALL SLIDES ++]-->
<?php } elseif (get_option('mp_slides_content') === "image_s") { ?>
<!--[image slider start]-->
<!--[BEGIN: ALL SLIDES ++]-->
<div class="slide clearfix">
<!-- thumbnail start -->
<?php if (get_option('mp_slides_style') === "fixed") { ?>
<?php mp_thumb('featured-thumbnail','featured-slider-image920','920'); //Theme function ?>
<?php } else { ?>
<?php mp_thumb('featured-thumbnail','featured-slider-image960','960'); //Theme function ?>
<?php } ?>
<!-- end of thumbnail -->
</div>
<!--[END: ALL SLIDES ++]-->
<!--[end of image slider]-->
<?php } ?>
<?php endwhile;
} // end for() loop number 2
?>
</div>
<!--[END: Slides_container]-->
<a href="#" class="prev"></a>
<a href="#" class="next"></a>
</div>
<!--[END: #Slides]-->
</div>
<!--[END: Slider wrapper]-->
</div>
//theme function
are nothing but switching the class for style
--[ Resolved Code ]------------------------------------------------------------------- As I am new to php I didn't realized I am using two loop at the same time for and while. With Manny Fleurmond's comment my mind just clicked and I use below code and it just works fine with me. Also changed post_per_page option as m0r7if3r said. Please tell me if anything is wrong in this code.
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('category_name='.get_option('mp_featured_cat').'&posts_per_page='.get_option('mp_slides_no').'');
while ( $wp_query->have_posts() ) : $wp_query->the_post(); // loop for posts
?>
showposts
, it's WAY old. It has been replaced byposts_per_page
. This is not your issue though.