我是使用Wordpress的新手,我创建了一个包含很长项目列表的页面.
* Item 1
* Item 2
* Item 3
* Item 4 ... and so on
Run Code Online (Sandbox Code Playgroud)
我打算在一个单独的页面上嵌入包含很长项目列表的页面.我该怎么办?我在网上跟着教程,并得到把这段代码的想法add_post_type_support( 'page', 'excerpt' );上functions.php.放入代码后,您可以在创建/编辑页面时使用新选项.但在那之后,我如何显示我的页面摘录?
rav*_*tel 17
首先将此代码放在主题function.php文件中.
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
Run Code Online (Sandbox Code Playgroud)
之后启用页面摘录见下图定义图像:

使用此代码获取页面摘录:
<?php echo get_the_excerpt(); ?>
<?php
query_posts("page_id=36");
while ( have_posts() ) : the_post()
?>
<h1><a href="<?php echo the_permalink(); ?>"><?php echo get_the_title(); ?></a></h1>
<?php the_excerpt(); ?>
<?php
endwhile;
wp_reset_query();
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15414 次 |
| 最近记录: |