2012-03-25 20 views
2

我需要在wordpress中創建一個圖庫以顯示最新的3個帖子。圖庫將顯示帖子的圖像,帖子的標題和帖子的一部分(wordpress中的--more--標籤之前的段落)。我需要它是動態的,當我添加一個新的畫廊顯示的帖子。如何在Wordpress中創建內容滑塊

好,我做了下面的代碼

<div class="blogsgallery"> 

     <?php query_posts('showposts=3'); ?> 

     <?php while (have_posts()) : the_post(); ?> 
     <p> 
     <h3> 
      <a href="<?php the_permalink() ?>" 
rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> 
       <?php the_title(); ?></a> 
     </h3> 
     </p> 

     <div class="entry-content"> 

      <div id="post-thumbnail"> 
       //the size of thumbnail 150X150 px 
       <?php the_post_thumbnail(array(150,150)); ?> 
      </div> 

//The code will show only the text before the "Read More ..." tag ! 
       <?php 
       global $more; 
       $more = 0; 
       the_content("Read More ..."); 
       ?> 
     </div> 

     <?php endwhile; ?> 

    </div> 

這是一個循環,以顯示最新的3個員額。我需要使它成爲一個滑塊容器。在特定的時間後,即一分鐘,滑1個向左移動和顯示幻燈片2,等等

請參閱有關更多信息,照片:

enter image description here

回答

1

最簡單的解決方法是更改通過您的設置顯示的帖子數量。我想這對你來說不是一個好的解決方案。這裏是另一種方法:

您需要編輯主題中的頁面。您可以編輯主頁面;我建議你make a new page template並用它作爲你的頭版。

然後您創建和query_posts的變體。創建具有3個(每頁)的循環將這樣進行:

query_posts('posts_per_page=3'); 

查看更多信息在the Wordpress codex;特別是template tags頁面。

+0

鏈接:[查詢回覆](http://codex.wordpress.org/Function_Reference/query_posts)[循環](http://codex.wordpress.org/The_Loop)[template_tags]( http://codex.wordpress.org/Template_Tags)[創建一個頁面模板](http://codex.wordpress.org/Pages#Page_Templates) – Brtrnd 2012-03-25 13:25:49

+0

謝謝...但我怎麼做的職位畫廊?如果它是純html,則爲 – 2012-03-25 13:45:23

+0

;將其創建爲靜態文件;在此之後,你將不得不看看你的循環是如何適應的。 – Brtrnd 2012-03-28 06:51:43

0

Btrnd在技術上是正確的。但是,您似乎無法理解Wordpress模板的工作原理。 (我不是故意冒犯)。也許你正在尋找一個插件來爲你做?

http://speckyboy.com/2010/06/30/top-10-content-slider-plugins-for-wordpress/

你可以嘗試在上面的帖子什麼。要安裝插件,請下載並將其插入您的插件目錄中。或者,您可以直接從Wordpress搜索插件並從Wordpress後端安裝它們。有關如何執行此操作,請參閱代碼(下面的鏈接)。

http://codex.wordpress.org/Managing_Plugins#Installing_Plugins

+0

沒關係沒問題。我需要從頭開始,並且需要動態,當我插入新帖子時,它立即顯示帖子。 – 2012-04-01 08:46:46