1. 如何實現WordPress 首頁不顯示文章全文
方法一:
就在編輯文章的上面,找到「插入『More』標簽(Alt+Shift+T)」你想首頁顯示那一段,就在那段後面加上這個,方法很簡單,就是每次編輯文章不能忘記按了。
方法二:
在你主題文件夾下面的index.php頁面,找到一段類似
<?phpthe_content(__('More>>'));?>
的代碼,如果找不到,Ctrl+F找
phpthe_content
一般只會有一句這個代碼,這一排代碼就是輸出整篇文章內容的。換成:
<?php
if(has_excerpt())
{the_excerpt();?>
<arel="more-link"href="<?phpthe_permalink()?>"title="<?phpthe_title();?>">>>閱讀全文<<</a>
<?php}
else{
echomb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,500,"......");?>
<arel="more-link"href="<?phpthe_permalink()?>"title="<?phpthe_title();?>">>>閱讀全文<<</a>
<?php}//endelse?>
簡單的解釋下這段代碼有什麼用。
如果你不寫編輯框下面的摘要,首頁只顯示文章的500個文字。如果你寫了摘要,首頁只顯示摘要裡面的內容。是不是很人性化呢?
效果看看我的首頁就知道啦~~~