Wordpress在两列表格中显示自定义帖子类型
我试图显示一个自定义帖子类型,并在页面上以两列表格格式显示查询。目前,我已经能够让它显示在单独的行中,而不是列中,并且出于某种原因,该表显示了两次。我知道这可能涉及到一些严重的编码,我相当擅长PHP,但仍在学习中。以下是指向相关页面的链接:。以下是我目前拥有的代码,如有任何帮助,将不胜感激:Wordpress在两列表格中显示自定义帖子类型,wordpress,html-table,multiple-columns,custom-post-type,Wordpress,Html Table,Multiple Columns,Custom Post Type,我试图显示一个自定义帖子类型,并在页面上以两列表格格式显示查询。目前,我已经能够让它显示在单独的行中,而不是列中,并且出于某种原因,该表显示了两次。我知道这可能涉及到一些严重的编码,我相当擅长PHP,但仍在学习中。以下是指向相关页面的链接:。以下是我目前拥有的代码,如有任何帮助,将不胜感激: <table> <tbody> <?php $listings = new WP_Query( array('post_type' =>
<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: ', ', ', ' lbs.</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'expected_size', 'Expected Size: ', ', ', ' 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>
好的,我在这个自定义帖子类型中又添加了一些列表,看起来该表的重新填充次数与posts.Nevermind相同。我自己想出来的。任何想知道的人都可以在这里找到参考资料。我尝试了两种方法,两种方法都有效,但是在CSS版本中调整对齐方式更容易。