In Taxonomy.php (Create on if have none) in your template folder
You should have something similer to this code:
(分类法与archive.php类似,但用于自定义帖子类型)
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!--=== TO GET THE TAXONOMY TITLE ===-->
<h1><?php $term = get_term_by( \'slug\', get_query_var( \'term\' ), get_query_var( \'taxonomy\' ) ); echo $term->name; ?></h1>
<?php endwhile; ?>
<?php endif; ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
// FIELDS NAME SHOULD REPLACE \'custom_field_name\'
$meta_value = get_post_meta($post->ID, \'custom_field_name\', true);
$meta_value2 = get_post_meta($post->ID, \'custom_field_name2\', true);
//THUMBNAIL
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,\'large\');
$image_url = $image_url[0];
?>
<div class="productContainer">
<?php echo get_the_post_thumbnail($post->ID, \'thumbNameDefined\'); ?>
<h3><?php the_title(); ?></h3>
Value of something: <?php echo $meta_value; ?>
Value of some Other thing: <?php echo $meta_value2; ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
。
在函数中。php您应该“启用”自定义帖子类型的缩略图,就像您在常规帖子中一样。。。以下是我当前正在构建的主题中的一些自定义帖子类型的行:
add_theme_support( \'post-thumbnails\', array( \'post\', \'engagement_ring\', \'wedding_ring\') ); // Add support for posts and custom post type
add_image_size( \'post\', 250, 175, true );
add_image_size( \'engagement_ring\', 300, 300 );
add_image_size( \'wedding_ring\', 300, 300);
请注意,您应该将我添加的第一个代码中的“thumbNameDefined”一词替换为自定义帖子类型的名称,以便它出现。。
这是(我认为)avrage 5岁的孩子可以嵌入的信息,所以我希望它能帮助你
干杯,萨吉夫。