2013-11-22 66 views
0

我是網絡開發初學者。我使用自定義主題(underscore.me)在WordPress中創建網站。我需要在網站上製作兩張桌子。第一個表是「過去的項目」,第二個是「未來的項目」。 我創建該表的自定義後類型:調用(屬性), 自定義後鍵入「屬性」顯示: 1.Past項目或今後的項目 2.Property名稱 3.Property照片 4.Property地址 5.Property日期 6.Property APTS 7.Property尺寸 8.Property狀態 9 ...WordPress的,自定義主題,自定義帖子類型

這是我這個表HTML:

<div id="main-content"> 
<div class="container"> 
    <div class="sixteen columns"> 
     <div class="tab-content sixteen columns"> 
      <div class="tab-pane active" id="table1"> 
      <p class="table-name">Featured Projects</p> 
       <table class="footable tablet footable-loaded"> 
       <thead> 
        <tr> 
        <th data-class="expand" data-sort-initial="true" class="footable-sortable footable-sorted footable-first-column"> 
         <span title="table sorted by the column on load">Project</span> 
         <span class="footable-sort-indicator"></span> 
        </th> 
        <th class="footable-sortable"> 
         <span title="sorting disabled on this column">Photos</span> 
         <span class="footable-sort-indecator"></span> 
        </th> 
        <th class="footable-sortable"> 
         Address 
         <span class="footable-sort-indecator"></span> 
        </th> 
        <th data-hide="phone" data-type="numeric" class="footable-sortable"> 
         Year 
         <span class="footable-sort-indecator"></span> 
        </th> 
        <th data-hide="phone" data-type="numeric" class="footable-sortable"> 
         APTS 
         <span class="footable-sort-indecator"></span> 
        </th> 
        <th data-hide="phone" data-type="numeric" class="footable-sortable"> 
         SQ. FT 
         <span class="footable-sort-indecator"></span> 
        </th> 
        <th data-hide="phone" data-type="numeric" class="footable-sortable"> 
         STATUS 
         <span class="footable-sort-indecator"></span> 
        </th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
        <td class="expand footable-first-column"> 
         <a href=""></a> 
        </td> 
        <td> 
        <a class="photo-icon" href="">Photo</a> 
        </td> 
        <td>21-45 45th Drive-Long Island City</td> 
        <td>2010</td> 
        <td>23</td> 
        <td>30,000</td> 
        <td class="footable-last-column">In Development</td> 
        </tr> 
        <tr> 
        <td class="expand footable-first-column"> 
         <a href="">The Industry</a> 
        </td> 
        <td> 
         <a class="photo-icon" href="">Photo</a> 
        </td> 
        <td>21-45 45th Drive-Long Island City</td> 
        <td>2010</td> 
        <td>23</td> 
        <td>30,000</td> 
        <td class="footable-last-column">In Development</td> 
        </tr> 
       </tbody> 
       </table>  
      </div>  
     </div> 
    </div> 
    </div> 

問題:如何在我的自定義主題頁面中使用php查詢顯示來自特定帖子類型(自定義帖子類型)的帖子,以及如何使用PHP查詢使該功能輕鬆創建或刪除「過去的項目」或「未來項目」。

我會很感激,如果有人能幫助我。再次感謝你。

回答

1

你讓自己變得更加困難。你不需要創建任何額外的數據庫表,除非你真的很想...

這是不是當網站訪問者點擊鏈接查看自定義帖子類型時會發生什麼。 (僞代碼)

select * from wp_customPostType 

它是這樣的:

select * from wp_posts where posts.post_type = 'custom_post_type' 

這是你怎麼做。 (你做它的順序沒有差別)

  1. Use this post type generator創建自定義後類型,但只能使一個叫項目it's DRYer),並啓用 分類。
  2. 在您的主題目錄中複製single.php,將其粘貼並將 名稱更改爲single-Projects.php。
  3. 在主題functions.php(你實際上應使用孩子 的主題,如果你沒有的話)註冊新的職位類型有?php register_post_type($post_type, $args) ?>

  4. 在single.php中(的一部開拓創新,而不是一個您複製)添加如下內容:

  5. if ('Project' == get_post_type()) 
    { 
    use single-Project.php 
    } 
    else 
    { 
    continue using this page (single.php) 
    

    你將不得不創造單Project.php新的佈局,但那麼所有你需要做的是對過去和未來的加分類的項目,你創建。當未來成爲過去時,你所要做的就是改變分類標準,而不是爲過去的項目發佈一個新帖子。

+0

非常感謝! –

+0

沒問題...請您選擇它作爲正確的答案? – stink

相關問題