2012-03-23 58 views
0

我想完成'主題'我的Wordpress/jQuery/JS滑塊;我現在有它在哪裏它成功地抓住最新的WordPress的帖子,但沒有完全循環他們在主'特色窗口'? (JavaScript錯誤?)另外,我還沒有能夠成功地添加'featured_image'來允許設置'特色窗口'中使用的圖像。添加'精選Imgs'到我的WordPress滑塊/旋轉通過?

我在基地問題通過一定的幫助遠遠得到這個:'Themeing' my Slider in WP with PHP

下面是我使用的代碼:

<?php 
/** 
* @package WordPress 
* @subpackage Default_Theme 
*/ 
$pagePtr="home"; 
include @ ("header.php"); 
//get_header(); ?> 

<div id="content"> 


    <?php 
/** 
* @package WordPress 
* @subpackage Default_Theme' 

*/ 

//get_header(); ?>   
<div id="content"> 

<?php if (have_posts()) : ?> 

<!--Your slider code goes here--> 

      <?php 
      $args = array(
       'numberposts'  => 5, 
       'orderby'   => 'post_date', 
       'order'   => 'DESC' 
      ); 
      $posts_array = get_posts($args); 
      ?>  
     <div id="featured" > 
     <ul class="ui-tabs-nav"> 

      <?php 
      $i = 1; 
      foreach ($posts_array as $post) : setup_postdata($post); 
      ?> 
      <li class="ui-tabs-nav-item ui-tabs-selected" id="nav-fragment-<?php echo $i; ?>"><a href="#fragment-1"><img src="<?php echo $featured_image; ?>" alt=""/><span><?php the_title(); ?><br /><p class="info" style="padding-left:10px;"><?php the_excerpt(); ?></p></span></a></li> 
      <?php $i++; 
      endforeach; ?> 
     </ul> 
      <?php 
      $i = 1; 
      foreach ($posts_array as $post) : setup_postdata($post); 
      ?> 
     <!-- First Content --> 
     <div id="fragment-<?php echo $i; ?>" class="ui-tabs-panel" style=""> 
      <img src="<?php the_post_thumbnail('slider_image'); ?>" alt="" /> 
      <div class="info" > 
      <h2><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2> 
      <p><?php the_excerpt(); ?><a href="<?php the_permalink(); ?>" >read more</a></p> 
      </div> 
     </div> 
     <?php $i++; endforeach; ?> 


    </div> 

<!--Your slider code goes here--> 
<!-- End Featured Lists Image Slider -->   

<?php endif; ?> 

     <?php if($featured_image= get_post_meta($post->ID, "featured_image", true)) { ?> 
     <div class="postThumbnail"><a href="<?php the_permalink() ?>"><img src="<?php echo $featured_image; ?>" height="190" width="125" border="0" /></a></div> 
     <?php } ?> 

真人版通過我的測試site:http://tinyurl.com/7q3o97u

請注意右邊的方框是如何正確工作的,而bri在最近發佈的帖子中有過 - 但由於某些原因,主要區域/留下較大的窗口,行爲不一樣?我怎樣才能正常工作?

回答

1

我不知道這是你的問題的根本原因,但此行:

<img src="<?php the_post_thumbnail('slider_image'); ?>" alt="" /> 

導致的加價問題。它呈現:

<img src="<img width="940" height="340" src="http://www.osmproduction.com/RIF/wp-content/uploads/2012/03/MaxBrooksRecordedAttacks-940x340.png" class="attachment-slider_image wp-post-image" alt="MaxBrooksRecordedAttacks" title="MaxBrooksRecordedAttacks" />" alt="" /> 

這是不對的。 the_post_thumbnail返回完整的HTML img標記,而不僅僅是圖片網址。試着用

<?php the_post_thumbnail('slider_image'); ?> 
更換

<img src="<?php the_post_thumbnail('slider_image'); ?>" alt="" />