WordPress 文章页面如何调用摘要?

给自己网站添加了360智能摘要,便于收录,其中有一行,需要在文章页的head标签中调用文章摘要,自己采用了get_the_excerpt和get_the_content函数都不行。不知该如何处理?

<meta property="og:description" content="<?php get_the_excerpt();?>"/>
阅读 7.3k
2 个回答
/**
 * 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 length
function custom_excerpt_length(){
  return 250;
 }
add_filter( 'excerpt_length', 'custom_excerpt_length' );
// set the excerpt more text
function 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; 
    } 
} 
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题