2012-03-05 5 views
0

私はワードプレスでデバッグモードで問題に直面しています。エラー Notice: Object of class WP_Query could not be converted to int in on lineWordpress:Notice:クラスWP_Queryのオブジェクトは、行内のintに変換できませんでした

を取得私の特色のスライダーでは、私は私のスライダーのためのコードの下に

<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を使用していますがそうではない、forループを削除する必要がありますスタイル

答えて

1

のクラスを切り替えるに過ぎません$ featuredPostsは有効なintフィールドであると考えています。これはおそらくそれが不満なものです。have_posts()中に何度も投稿しています。have_posts()

<?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 
       ?> 
+0

いいえ、何も変更されません。ループのために問題を作成できますか? –

+1

for($ i = 1; $ i <= $ featuredPosts; $ i ++) '<---これもできますか? featuredPostsは数字ではありません。私はforループを削除し、それが修正されているかどうかを確認します。 –

+0

返信を遅らせて申し訳ありませんBrain Garson。私は問題を解決しました。あなたは正しいです...私は同時に2つのループを使用することでそれを知らなかったし、それはエラーを引き起こしていた。私はループを削除して完了しました...ありがとうたくさん –

関連する問題