好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

WordPress获取文章内容摘要程序代码 - WordPress

WordPress获取文章内容摘要程序代码

本文章来给大家介绍WordPress获取文章内容摘要程序代码,第一个函数是讲述了可以获取所有文章内容摘要,另一个是在首页只显示第一个记录的文章内容摘要.

这个是我自己写的获取文章内容摘要程序,代码如下:

<?php    global   $more ;      $more  = 1;     //1=全文 0=摘要      $my_content  =  strip_tags (get_the_excerpt(),  $post ->post_content);  //获得文章      $my_content  =  str_replace ( array ( "rn" ,  "r" ,  "n" ,  " " ,  "t" ,  "o" ,  "x0B" , "" ")," ", $my_content );   //删除空格等   如果 不想删除请直接吧这行前面 加上//     $my_content  = mb_strimwidth( $my_content , 0, 500, "..."   );   //摘要前500字节     if  (mb_strlen( $my_content , 'utf-8' ) < 10){  echo   "对不起没有摘要" ;  }     //少于10字节提示语言     else   echo   $my_content ;   ?> 

首页第一篇显示全文,其他显示摘要,内容输出部分改成以下代码:

if (! $first ){  $first  = 1;  $more  = 1;  the_content();  $more  = 0;  }  else  {  the_excerpt();  //或者使用the_content();   } 

查看更多关于WordPress获取文章内容摘要程序代码 - WordPress的详细内容...

  阅读:48次