首页 文章

Wordpress,自定义主题,自定义帖子类型

提问于
浏览
0

我是网络开发的初学者 . 我正在使用自定义主题(underscore.me)在WordPress中创建网站 . 我需要在网站上制作两张 table . 第一个表是“过去的项目”,第二个表是“未来项目” . 我为此表创建了自定义帖子类型:call(属性),自定义帖子类型“Properties”显示:1.Past项目或Future Project 2.Property Name 3.Property Photo 4.Property Address 5.Property Date 6.Property apts 7.Property Size 8.Property Status 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查询创建功能以轻松创建或删除“过去项目”或“未来项目” .

如果有人可以帮助我,我将非常感激 . 再次感谢你 .

1 回答

  • 1

    你让自己变得更加困难 . 您不需要创建任何其他数据库表,除非您真的想...

    这是 not 当网站访问者点击链接查看自定义帖子类型时会发生什么 . (伪代码)

    select * from wp_customPostType
    

    它是这样的:

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

    这就是你如何做到的 . (你做的顺序没有区别)

    • Use this post type generator创建自定义帖子类型但只创建一个名为 Projectsit's DRYer )并启用分类法 .

    • 在主题目录中复制single.php,粘贴它并将名称更改为single-Projects.php .

    • 在你的主题's functions.php (you should actually be using a child theme if you'尚未登录_1176522_注册新的帖子类型

    • 在single.php(orignal,而不是你复制的那个)中添加如下内容:

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

    您必须为单个Project.php创建新布局,但接下来要做的就是为您创建的项目添加过去和将来的分类 . 当未来成为过去时,您所要做的就是更改分类,而不是为过去的项目创建新帖子 .

相关问题