
正文
wordpress获取页面正文 wordpress所有文章怎么显示
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
WordPress,发布的文章在页面上是全文显示,我想要的是显示文章摘要。不用插件,只用代码。效果
直接在写文章的时候添加手动摘要就行,如果还是不行,就用
?php if($has_thumbnail) :?
div class="post-thumbnail"a href="?php the_permalink() ?" rel="bookmark"img src="?=$thumbnail["src"];?" alt="?php the_title();?" //a/div
div class="post-content"
?php if(has_excerpt())
echo "p" . mb_strimwidth(strip_tags($post-post_excerpt),0,290,'…'). "/p";//判断是否存在手动摘要,并截取输出
else echo "p" . mb_strimwidth(strip_tags(apply_filters('the_content', $post-post_content)), 0, 290,"..."). "/p";?
/div
?php else :?
div class="post-content"
?php if(has_excerpt()) the_excerpt(); //判断是否存在手动摘要,并完整输出
else echo "p" . mb_strimwidth(strip_tags(apply_filters('the_content', $post-post_content)), 0, 460,"..."). "/p";?
/div
?php endif;?
# code from :
里面的css样式ID根据自己的来调整。
相关问答
Q1: wordpress 怎么调用页面文章的标题和内容呢
the_title();可以获取标题
the_content(); 可以获取内容
这两个函数都需要在posts里面执行
Q2: 如何在WordPress首页调用某页面的文章内容
你可以用超链接到那个相应的文章也面就可以了呀 a ref。。。。这种形式,在网上一查就知道了!
Q3: 自己建的一个wordpress页面模版是怎么获取自己想要的内容的??
wp是博客,获取自己想要的内容,只能百度搜索下,或者自己原创了。
Q4: wordpress 调用指定页面的内容及缩略图
wordpress可以通过 get_page() 函数,来获得指定ID的页面的内容、标题等信息,详情如下:
?php echo mb_strimwidth(get_page(16)-post_content,0,600); ?
如果调用图片,直接百度看看吧。
Q5: 如何获取 WordPress 各类页面的链接
获取文章或页面链接
直接输出文章或页面的链接:
1
?php the_permalink(); ?
返回文章或页面的链接,以供调用:
1
get_permalink();
可以使用 echo 输出,结果和直接使用 the_permalink() 一样:
1
?php echo get_permalink(); ?
获取存档页面链接
function get_current_archive_link( $paged = true ) {
$link = false;
if ( is_front_page() ) {
$link = home_url( '/' );
} else if ( is_home() "page" == get_option('show_on_front') ) {
$link = get_permalink( get_option( 'page_for_posts' ) );
} else if ( is_tax() || is_tag() || is_category() ) {
$term = get_queried_object();
$link = get_term_link( $term, $term-taxonomy );
} else if ( is_post_type_archive() ) {
$link = get_post_type_archive_link( get_post_type() );
} else if ( is_author() ) {
$link = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
} else if ( is_archive() ) {
if ( is_date() ) {
if ( is_day() ) {
$link = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
} else if ( is_month() ) {
$link = get_month_link( get_query_var('year'), get_query_var('monthnum') );
} else if ( is_year() ) {
$link = get_year_link( get_query_var('year') );
}
}
}
if ( $paged $link get_query_var('paged') 1 ) {
global $wp_rewrite;
if ( !$wp_rewrite-using_permalinks() ) {
$link = add_query_arg( 'paged', get_query_var('paged'), $link );
} else {
$link = user_trailingslashit( trailingslashit( $link ) . trailingslashit( $wp_rewrite-pagination_base ) . get_query_var('paged'), 'archive' );
}
}
return $link;
}
该函数可以输出首页、分类法(自定义分类法、标签、分类)、自定义文章类型的存档页面、作者存档页面、日期存档页面 的链接,包含分页。
获取当前页面链接
如果你不想判断页面类型,只想输出当前页面的链接,可以使用下面的代码:
?php
global $wp;
$current_url = home_url(add_query_arg(array(),$wp-request));
echo $current_url;
?
关于wordpress获取页面正文和wordpress所有文章怎么显示的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







