【发布时间】:2016-07-15 19:58:00
【问题描述】:
我正在尝试格式化具有自定义类型的单个帖子页面模板。我正在使用完全显示帖子内容的 the_content(),但是如何调用各个内容字段以便我可以将它们排列在模板中?
functions.php
function stories_init() {
$args = array(
'label' => 'Stories',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'stories'),
'query_var' => true,
'menu_icon' => 'dashicons-video-alt',
'supports' => array(
'title',
'editor',
'custom-fields',
'thumbnail',)
);
register_post_type( 'stories', $args );
}
single-post.html
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
【问题讨论】:
-
您想与什么交流如何调用各个内容字段以便我可以在模板中排列它们? 顺便说一句;您可以创建一个名为:. “single-stories.php”并在该文件中进行所有自定义...
-
我想访问不同 div 中的内容。例如,我希望标题出现在与编辑器中的文本不同的列中。所以我试图只返回自定义字段。
标签: php wordpress custom-wordpress-pages