Wordpress在两列表中显示自定义帖子类型

时间:2014-06-17 14:26:47

标签: wordpress html-table multiple-columns custom-post-type

我正在尝试显示自定义帖子类型,并在页面上以两列表格式显示查询。目前,我已经能够将它显示在单独的行而不是列中,并且由于某种原因,表格显示两次。我知道这可能涉及一些严肃的编码,我相当擅长PHP,但我还在学习。以下是相关网页的链接:http://new.ynp2.com/pet-list/。以下是我目前的代码,任何帮助将不胜感激:

<table>
    <tbody>
            <?php $listings = new WP_Query( array('post_type' => 'phanimals') ); if( $listings->have_posts() ): while($listings->have_posts()): $listings->the_post(); ?>
            <tr>
            <td>
                     <?php
                                    // now get and display custom fields
                                    $tour_custom_fields = get_post_custom();
                                    if (trim($tour_custom_fields['Pup Name']['0']) != "") { ?>
                                           <h4><? echo $tour_custom_fields['Pup Name']['0']; ?></h4>
<?php
// Page thumbnail and title.
twentyfourteen_post_thumbnail();
?>
<br>

<?php }
           if (trim($tour_custom_fields['Date of Birth']['0']) != "") {
                    $tmpage = calculate_age_from_dob($tour_custom_fields['Date of Birth']['0']);
                    $tmpdob = calculate_friendly_dob($tour_custom_fields['Date of Birth']['0']);
                    echo '<span class="attrname">Age: </span><span class="attrval">' . $tmpage . '</span><br>';
                    echo '<span class="attrname">D.O.B.: </span><span class="attrval">' . $tmpdob . '</span><br>';
                                    }
?>


<?php echo get_the_term_list( $post->ID, 'animal_species', 'Species: ', ', ', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'animal_gender', 'Gender: ', ', ', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'animal_allergy_scales', 'Allergy Scale: ', ', ', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'animal_activity_levels', 'Activity Level: ', ', ', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'shedding', 'Shedding: ', ', ', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'weight_range', 'Weight Range: ', ', ', '&nbsp;lbs.</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'expected_size', 'Expected Size: ', ', ', '&nbsp;lbs.</p>' ); ?>
</div>


    <div class="entry-content3">
            <?php
                    the_content();
                    wp_link_pages( array(
                            'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
                            'after'       => '</div>',
                            'link_before' => '<span>',
                            'link_after'  => '</span>',
                    ) );

                    edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
            ?>

<!-- <?php
echo '<span class="about-species">'.__('<br><h3>About This Species:</h3><br> ', 'animal_species').'</span>';

$reating_terms = get_the_terms ($post->id, 'animal_species');
foreach ($reating_terms as $term){
    echo $term->description;
}
?>-->




    </div><!-- .entry-content -->
</article><!-- #post-## -->

            <?php endwhile; endif; ?>

            </td>
            </tr>

    </tbody>
    </table>

0 个答案:

没有答案