• I have two questions. I am displaying a table of information, the info is a custom post type. My current code:

    <table class="table">
            <tbody>
                <tr>
                    <td style="background:#1F5FA7; color:#FFF; font-weight:bold;">
                        Job Title
                    </td>
                    <td style="background:#1F5FA7; color:#FFF; font-weight:bold;">
                        Date Posted
                    </td>
                    <td style="background:#1F5FA7; color:#FFF; font-weight:bold;">
                        Closing Date
                    </td>
                    <td style="background:#1F5FA7; color:#FFF; font-weight:bold;">&nbsp;
    
                    </td>
                </tr>
                <?php $listings = new WP_Query( array('post_type' => 'job-listings') ); if( $listings->have_posts() ): while($listings->have_posts()): $listings->the_post(); ?>
                <tr>
                  <td>
                    <?php the_title() ?>
                  </td>
                  <td>
                    <?php echo get_the_date() ?>
                  </td>
                  <td>
                    <?php
    				$custom_fields = get_post_custom($listings->ID);
    				$end_dates = $custom_fields['End Date'];
    					foreach($end_dates as $key => $value) {
    						echo $value;
    					}
    				?>
                  </td>
                  <td>
                    <a href="#">View Details</a>
                  </td>
                </tr>
                <?php endwhile; endif; ?>
            </tbody>
        </table>

    My query works, and everything displays the way I need. My first question is this: How can I make the link that currently leads no where lead to the page where the single listing is displayed?

    Second question: I have created a template but it currently just displays all the posts of this type. Code:

    <div class="col-lg-9">
        <?php $listings = new WP_Query( array('post_type' => 'job-listings') ); ?>
          <?php if( $listings->have_posts() ): while($listings->have_posts()): $listings->the_post(); ?>
            <div class="page-content">
              <h2><?php the_title(); ?></h2>
              <?php the_content(); ?>
            </div>
          <?php endwhile; endif; ?>
    
           </div>
    
      </div>

    So all together what I need is to add a link to the listings template and the single template needs to display the correct single listing.

    Thanks for any help and advice.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Link to custom post type’ is closed to new replies.