我有一个名为“abstract”的自定义帖子类型,其中包含以下内容meta_input
阵列项目
$abstract_details = array(
\'post_title\' => $result->title,
meta_input\' => array(
\'abstract_id\' => $result->abstract_id,
\'title\' => $result->title,
\'author\' => $result->author,
\'writeup\' => $result->writeup,
\'ref\' => $result->ref,
),
\'post_type\' => \'abstract\',
\'post_status\' => \'publish\',
);
我想在各自的帖子中显示这些项目的内容,使用类似于下面的内容
<li style="list-style-type: none; text-align: justify;"><?php echo nl2br(esc_html(get_post_meta(get_the_ID(), \'writeup\', true))) ?></li>
<br>
<?php $isAvailRef = get_post_meta(get_the_ID(), \'ref\', true)?>
<?php $refTag = "References/Bibliography: "?>
<li style="list-style-type: none;"><b><?php if(!empty($isAvailRef)): echo $refTag; endif;?></b></li>
<li style="list-style-type: none;"><?php echo nl2br(esc_html($isAvailRef))?></li>
<br>
<li style="list-style-type: none;"><b>Student: </b><?php echo esc_html(get_post_meta(get_the_ID(), \'author\', true)) ?></li>
我对WordPress很陌生(坦率地说,一般都是编码),我一直想知道在什么地方真正包含上面的内容,而这些内容只能在帖子的内容中找到。我看到一些教程建议创建
content-abstract.php
归档并在其中添加详细信息,但这样做也会将整个帖子添加到帖子的摘录区域。
So the question is, 在何处包含HTML代码以显示CPT的详细信息,如下所示:
而不必在摘录中显示此内容?(如下所示)
如果有任何好处,下面是默认的内容
content.php
我正在使用的主题的文件
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php engage_mag_do_microdata(\'article\'); ?>>
<?php
global $engage_mag_theme_options;
$engage_mag_show_image = 1;
if(is_singular()) {
$engage_mag_show_image = $engage_mag_theme_options[\'engage-mag-single-page-featured-image\'];
}
$engage_mag_show_content = $engage_mag_theme_options[\'engage-mag-content-show-from\'];
$engage_mag_thumbnail = (has_post_thumbnail() && ($engage_mag_show_image == 1)) ? \'engage-mag-has-thumbnail\' : \'engage-mag-no-thumbnail\';
?>
<div class="engage-mag-content-container <?php echo $engage_mag_thumbnail; ?>">
<?php
if ($engage_mag_thumbnail == \'engage-mag-has-thumbnail\'):
?>
<div class="post-thumb">
<?php
engage_mag_post_formats(get_the_ID());
engage_mag_post_thumbnail();
?>
</div>
<?php
endif;
?>
<div class="engage-mag-content-area">
<header class="entry-header">
<div class="post-meta">
<?php
engage_mag_list_category(get_the_ID());
?>
</div>
<?php
if (is_singular()) :
the_title(\'<h1 class="entry-title" \' . engage_mag_get_microdata("heading") . \'>\', \'</h1>\');
else :
the_title(\'<h2 class="entry-title" \' . engage_mag_get_microdata("heading") . \'><a href="\' . esc_url(get_permalink()) . \'" rel="bookmark">\', \'</a></h2>\');
endif;
if (\'post\' === get_post_type()) :
?>
<div class="entry-meta">
<?php
engage_mag_posted_on();
engage_mag_read_time_words_count(get_the_ID());
engage_mag_posted_by();
?>
</div><!-- .entry-meta -->
<?php endif; ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
if (is_singular()) :
the_content();
else :
if ($engage_mag_show_content == \'excerpt\') {
the_excerpt();
} else {
the_content();
}
endif;
wp_link_pages(array(
\'before\' => \'<div class="page-links">\' . esc_html__(\'Pages:\', \'engage-mag\'),
\'after\' => \'</div>\',
));
?>
<?php
$engage_mag_read_more_text = $engage_mag_theme_options[\'engage-mag-read-more-text\'];
if ((!is_single()) && ($engage_mag_show_content == \'excerpt\')) {
if (!empty($engage_mag_read_more_text)) { ?>
<p><a href="<?php the_permalink(); ?>" class="read-more-text">
<?php echo esc_html($engage_mag_read_more_text); ?>
</a></p>
<?php
}
}
?>
</div>
<!-- .entry-content -->
<footer class="entry-footer">
<?php engage_mag_entry_footer(); ?>
</footer><!-- .entry-footer -->
<?php
/**
* engage_mag_social_sharing hook
* @since 1.0.0
*
* @hooked engage_mag_constuct_social_sharing - 10
*/
do_action(\'engage_mag_social_sharing\', get_the_ID());
?>
</div> <!-- .engage-mag-content-area -->
</div> <!-- .engage-mag-content-container -->
</article><!-- #post-<?php the_ID(); ?> -->
提前谢谢你。