2013-11-22 68 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

相关问题