更改

2012-09-03 29 views
1

我已經寫一個整潔的響應滑塊爲我的WordPress返回崗位的順序特集(隨意使用):更改

<?php 
    $responsive = 'on' != get_option('henrik_responsive_layout') ? false : true; 
    $featured_auto_class = ''; 
    if ('on' == get_option('henrik_slider_auto')) $featured_auto_class .= ' et_slider_auto et_slider_speed_' . get_option('henrik_slider_autospeed'); 
?> 
<div id="featured" class="<?php if ($responsive) echo 'flexslider' . $featured_auto_class; else echo 'et_cycle'; ?>"> 
    <a id="left-arrow" href="#"><?php esc_html_e('Previous','henrik'); ?></a> 
    <a id="right-arrow" href="#"><?php esc_html_e('Next','henrik'); ?></a> 

<?php if ($responsive) { ?> 
    <ul class="slides"> 
<?php } else { ?> 
    <div id="slides"> 
<?php } ?> 
     <?php global $ids; 
     $ids = array(); 
     $arr = array(); 
     $i=0; 

     $featured_cat = get_option('henrik_feat_cat'); 
     $featured_num = (int) get_option('henrik_featured_num'); 

     if (get_option('henrik_use_pages') == 'false') query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat)); 
     else { 
      global $pages_number; 

      if (get_option('henrik_feat_pages') <> '') $featured_num = count(get_option('henrik_feat_pages')); 
      else $featured_num = $pages_number; 

      query_posts(array 
          ('post_type' => 'page', 
          'orderby' => 'menu_order', 
          'order' => 'ASC', 
          'post__in' => (array) get_option('henrik_feat_pages'), 
          'showposts' => (int) $featured_num 
         )); 
     } ?> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); 
     global $post; ?> 
     <?php if ($responsive) { ?> 
      <li class="slide"> 
     <?php } else { ?> 
      <div class="slide"> 
     <?php } ?> 
       <?php 
       $width = $responsive ? 960 : 958; 
       $height = 340; 
       $small_width = 95; 
       $small_height = 54; 
       $titletext = get_the_title(); 

       $thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Featured'); 

       $arr[$i]['thumbnail'] = get_thumbnail($small_width,$small_height,'',$titletext,$titletext,false,'Small'); 
       $arr[$i]['titletext'] = $titletext; 

       $thumb = $thumbnail["thumb"]; 
       print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?> 
       <div class="featured-top-shadow"></div> 
       <div class="featured-bottom-shadow"></div> 
       <div class="featured-description"> 
        <div class="feat_desc"> 
         <p class="meta-info"><?php esc_html_e('Posted','henrik'); ?> <?php esc_html_e('by','henrik'); ?> <?php the_author_posts_link(); ?> <?php esc_html_e('on','henrik'); ?> <?php the_time(esc_attr(get_option('henrik_date_format'))) ?></p> 
         <h2 class="featured-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
         <p><?php truncate_post(410); ?></p> 
        </div> 
        <a href="<?php the_permalink(); ?>" class="readmore"><?php esc_html_e('Read More', 'henrik'); ?></a> 
       </div> <!-- end .description --> 
     <?php if ($responsive) { ?> 
      </li> <!-- end .slide --> 
     <?php } else { ?> 
      </div> <!-- end .slide --> 
     <?php } ?> 
     <?php $ids[] = $post->ID; $i++; endwhile; endif; wp_reset_query(); ?> 
<?php if ($responsive) { ?> 
    </ul> <!-- end .slides --> 
<?php } else { ?> 
    </div> <!-- end #slides --> 
<?php } ?> 
</div> <!-- end #featured --> 

<div id="controllers" class="clearfix"> 
    <ul> 
     <?php for ($i = 0; $i < $featured_num; $i++) { ?> 
      <li> 
       <div class="controller"> 
        <a href="#"<?php if ($i == 0) echo ' class="active"'; ?>> 
         <?php print_thumbnail($arr[$i]['thumbnail']['thumb'], $arr[$i]['thumbnail']["use_timthumb"], $arr[$i]['titletext'], $small_width, $small_height); ?> 
         <span class="overlay"></span> 
        </a> 
       </div> 
      </li> 
     <?php } ?> 
    </ul> 
    <div id="active_item"></div> 
</div> <!-- end #controllers --> 

它選擇一個自定義類別,並返回崗位的定製量。問題是它會按照創建順序顯示帖子。 我想選擇我自己的訂單,以便我可以選擇首先顯示哪些帖子等等。

那麼,是不是可以選擇其中責令退回帖子顯示?也許針對特定的ID?

回答

0

看起來你已經使用'orderby' => 'menu_order'這樣做。您現在需要做的就是在WordPress界面中設置菜單順序 - 所有新帖子默認爲0。或者您將orderby參數更改爲something else

+1

能否請您詳細說明您的回覆,我知道我可以將訂單改爲各種選項,但是我不熟悉menu_order解決方案的工作方式?如何在Wordpress界面中爲** posts **設置menu_order? –

+0

啊,你使用'page'的帖子類型,所以我想你有這個選擇。技術上'menu_order'將適用於所有帖子類型,但沒有用於非分層帖子類型(即帖子)的界面。您可以將新帖子註冊爲分層​​。這取決於你的目標,但訂購博客文章沒有意義,因爲你添加更多,並保持發佈一個新的職位類型可能會爲你工作。 – developdaly

+0

我想要選擇的列表中唯一一個顯示的是第一個。你能找到一種方法,如何強制第一個顯示爲自定義ID(我直接在代碼中設置),其餘顯示爲返回時的順序?感謝您的時間。 –