Kirill Babak
Kirill Babak

Reputation: 1

Wordpress,Custom Theme,Custom Post Type

I'm beginner in web developing. I'm creating sites in WordPress with Custom theme (underscore.me). I need to make two tables in the site. First table is "past projects", the second one is "Future project". I created the custom post type for this table:call(Properties), Custom post type "Properties" show up: 1.Past project or Future Project 2.Property Name 3.Property Photo 4.Property Address 5.Property Date 6.Property apts 7.Property Size 8.Property Status 9...

This is my HTML for this tables:

<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>

Question: How to display posts from a specific post type(custom post type)using php queries in my custom theme page, and how to make the function with PHP queries to easily create or delete "past projects" or "future projects".

I would be so appreciated, if anybody can help me. Thank you again.

Upvotes: 0

Views: 238

Answers (1)

stink
stink

Reputation: 865

Your making it more difficult on your self. You don't need to create any additional database tables unless you really really want to...

This is not what happens when site visitor clicks on a link to view custom post types. (Pseudo Code)

select * from wp_customPostType

Its something like this:

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

This is how you do it. (The order you do it in makes no difference)

  1. Use this post type generator to create your custom post type but only make one called Projects (it's DRYer) and enable taxonomies.
  2. In your theme directory copy single.php, paste it and change the name to single-Projects.php.
  3. In your theme's functions.php (you should actually be using a child theme if you're not already) register the new post type with ?php register_post_type( $post_type, $args ) ?>

  4. In single.php (the orignal, not the one you copied) add something like this:

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

    You will have to create the new layout for single-Project.php but then all you have to do is add a taxonomy for past and future to the Projects that you create. When the future becomes the past all you have to do is change the taxonomy rather than make a new post for past projects.

Upvotes: 1

Related Questions