简体   繁体   English

wordpress博客首页自定义

[英]wordpress blog homepage customization

please don't give a negative feed like always and instead tell me the mistake. 请不要像往常一样提供否定的供稿,而要告诉我错误。

I have a blog. 我有一个博客。

can i make the homepage display a summary of an article instead of the whole article? 我可以使主页显示文章摘要而不是整个文章吗?

if yes then where or how can i do it? 如果是,那我在哪里或怎么办?

I have this pre-set in one of my WordPress sites. 我在我的WordPress网站之一中有此预设。 Here is what this looks like and it is in Appearance/Editor/Posts Page (home.php) 这是它的外观,它在外观/编辑器/帖子页面(home.php)中

    <div class="post-content">
        <?php $content = get_the_content(); ?>
        <?php echo wp_trim_words(strip_tags($content), 30); ?>
    </div>

<a class="blog-post-read-more" href="<?php echo esc_url( get_the_permalink( get_the_ID() ) ); ?>"><?php echo esc_html( get_theme_mod( 'relia_blog_read_more', __( 'Read More', 'relia' ) ) ); ?></a>

   </div>

So what this does is it will strip the words up to 30, wp_trim_words . 所以这样做是将最多删除 30个单词wp_trim_words And below that is the how to insert Read More. 下面是如何插入Read More。

Here are some links for you to check out: https://codex.wordpress.org/Excerpt https://codex.wordpress.org/Customizing_the_Read_More 以下是一些供您签出的链接: https : //codex.wordpress.org/Excerpt https://codex.wordpress.org/Customizing_the_Read_More

Create one custom template that template you can assign your home page

    /*
    Template Name: Blog
    */
        query_posts( array( 'post_type' => 'post', 'posts_per_page' => 6, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ) ) );

<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', get_post_format());  ?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
wp_reset_postdata();

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

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