WordPress 文章頁面如何調用摘要?

來源:互聯網
上載者:User
給自己網站添加了360智能摘要,便於收錄,其中有一行,需要在文章頁的head標籤中調用文章摘要,自己採用了get_the_excerpt和get_the_content函數都不行。不知該如何處理?

回複內容:

給自己網站添加了360智能摘要,便於收錄,其中有一行,需要在文章頁的head標籤中調用文章摘要,自己採用了get_the_excerpt和get_the_content函數都不行。不知該如何處理?

/** * Custom Post Excerpt */ function wn_get_the_title($limit) {  global $post;  $title = sysSubStr( get_the_title(), $limit, true );  return $title;}function wn_get_the_excerpt($limit) {  global $post;  $excerpt = sysSubStr( get_the_excerpt(), $limit, true );  return $excerpt;}function wn_get_the_content($limit) {  global $post;  $content = sysSubStr( get_the_content(), $limit, true );  return $content;}// set the excerpt lengthfunction custom_excerpt_length(){  return 250; }add_filter( 'excerpt_length', 'custom_excerpt_length' );// set the excerpt more textfunction custom_excerpt_more( $more ) {  return '……';}add_filter( 'excerpt_more', 'custom_excerpt_more' );function sysSubStr($string,$length,$append = false) {     if(strlen($string) <= $length )     {         return $string;     }     else     {         $i = 0;         while ($i < $length)         {             $stringTMP = substr($string,$i,1);             if ( ord($stringTMP) >=224 )             {                 $stringTMP = substr($string,$i,3);                 $i = $i + 3;             }             elseif( ord($stringTMP) >=192 )             {                 $stringTMP = substr($string,$i,2);                 $i = $i + 2;             }             else             {                 $i = $i + 1;             }             $stringLast[] = $stringTMP;         }         $stringLast = implode("",$stringLast);         if($append)         {             $stringLast .= "……";         }         return $stringLast;     } } 

    function kankana_get_meta_description(){        $description = '';        $length = 100;        //if on home page        if(is_home() || is_front_page()){            $description = get_bloginfo( 'description' );        }elseif(is_singular()){            //if viewing a post/page            global $post;            $striped_content = wp_strip_all_tags( remove_all_shortcodes($post->post_content), true);            $description = mb_substr( $striped_content, 0, $length );        }        //elseif(is_archive())        return $description;    }

usage

  
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.