简体   繁体   English

如何编辑Wordpress二十七:首页(front-page.php),使其仅显示内容片段

[英]How to edit Wordpress Twenty Seventeen: Homepage (front-page.php) so it only shows a snippet of content

My client's site crashed and she's currently relying on the default WordPress theme until she finds a new one 我客户的网站崩溃了,她目前正在使用默认的WordPress主题,直到找到新主题为止

In the meantime, I still want her to have a website that's user-friendly. 同时,我仍然希望她拥有一个用户友好的网站。 Here's the problem: the theme allows you to add front page sections and it pulls from pages that are already created, but it doesn't allow you to modify how much of that page is shown. 问题出在这里:主题允许您添加首页部分,并且从已创建的页面中提取,但不允许您修改显示的页面数量。 I have around 500 words on these pages for SEO purposes, but I don't want to create a messy front page that's clogged up with all of this information. 这些页面上大约有500个单词用于SEO,但是我不想创建一个混乱的首页,而这些首页已被所有这些信息所阻塞。 Instead, I just want to pull a snippet of information. 相反,我只想提取一小段信息。

Is there a way to do this? 有没有办法做到这一点? Here's the code: 这是代码:

 <?php /** * Displays content for front page * * @package WordPress * @subpackage Twenty_Seventeen * @since 1.0 * @version 1.0 */ ?> <article id="post-<?php the_ID(); ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> > <?php if ( has_post_thumbnail() ) : $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' ); // Calculate aspect ratio: h / w * 100%. $ratio = $thumbnail[2] / $thumbnail[1] * 100; ?> <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);"> <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div> </div><!-- .panel-image --> <?php endif; ?> <div class="panel-content"> <div class="wrap"> <header class="entry-header"> <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?> <?php twentyseventeen_edit_link( get_the_ID() ); ?> </header><!-- .entry-header --> <div class="entry-content"> <?php /* translators: %s: Name of current post */ the_content( sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ), get_the_title() ) ); ?> </div><!-- .entry-content --> </div><!-- .wrap --> </div><!-- .panel-content --> </article><!-- #post-## --> 

There is a setting for that in WordPress. WordPress中有一个设置。 Just select (in the backend): Settings > Reading > For each article in a feed, show > Summary 只需选择(在后端):设置>阅读>供稿中的每篇文章,显示>摘要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM