Wordpress,自定义主题,自定义文章类型


Wordpress,Custom Theme,Custom Post Type

我是网络开发的初学者。我正在WordPress中创建自定义主题的网站(underline.me)。我需要在网站中制作两个表。第一个表是"过去的项目",第二个表是"未来的项目"。我为这个表创建了自定义的post类型:call(Properties),显示自定义帖子类型"属性":1.过去的项目或未来的项目2.物业名称3.房产照片4.物业地址5.产权日期6.财产适用条款7.物业规模8.财产状况9…

这是我的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查询来创建或删除"过去的项目"或"未来的项目"。

如果有人能帮助我,我将不胜感激。再次感谢。

你让自己变得更加困难。你不需要创建任何额外的数据库表,除非你真的想…

这是而不是当网站访问者点击链接查看自定义帖子类型时会发生的情况。(伪码)

select * from wp_customPostType

它是这样的:

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

你就是这样做的。(你做的顺序没有区别)

  1. 使用此帖子类型生成器创建您的自定义帖子类型,但只创建一个名为项目它是DRYer)并启用分类法
  2. 在您的主题目录中复制single.php,粘贴它并更改name到singleProjects.php
  3. 在主题的functions.php中(您实际上应该使用一个child主题(如果你还没有)向注册新的帖子类型?phpregister_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)
    

    您必须为singleProject.php创建新布局,但您所要做的就是将过去和未来的分类法添加到您创建的项目中。当未来成为过去时,你所要做的就是更改分类法,而不是为过去的项目发布新的帖子。