2016-08-25 135 views
1

請不要像總是給負面的飼料,而是告訴我的錯誤。wordpress博客主頁定製

我有一個博客。

我可以使主頁顯示文章的摘要而不是整篇文章嗎?

如果是,那麼我在哪裏或如何做到這一點?

+1

你可以用['get_the_excerpt(帖子ID)'](https://codex.wordpress.org/取sumary的textarea Function_Reference/get_the_excerpt),或者你可以獲得內容並用['substr'](http://php.net/manual/en/function.substr.php)限制內容的字數 –

回答

1

我已經在我的一個WordPress站點中預設了該設置。下面是這個樣子,它是在外觀/編輯/帖子頁(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> 

那麼這樣做是將剝離的話可達30 wp_trim_words。在下面是如何插入閱讀更多。

這裏有一些鏈接,你看看: https://codex.wordpress.org/Excerpt https://codex.wordpress.org/Customizing_the_Read_More

1
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();