首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏ytkah

    wordpress如何正确自动获取中文日志摘要

    function get_post_excerpt($post, $excerpt_length=240){ if(! $post) $post = get_post(); $post_excerpt = $post->post_excerpt; if($post_excerpt == ''){ = mb_strimwidth($post_content,0,$excerpt_length,'…','utf-8'); } $post_excerpt = wp_strip_all_tags ( $post_excerpt ); $post_excerpt = trim( preg_replace( "/[\n\r\t ]+/", ' ', $post_excerpt ), ' ' php echo get_post_excerpt(); ?>

    68610编辑于 2022-03-14
  • 来自专栏WordPress果酱

    WordPress 技巧:正确获取文章摘要

    我们知道通过 WordPress 函数 get_the_excerpt() 可以获取日志的摘要,如果没有摘要,它会自动获取内容,并且截取。 function get_post_excerpt($post, $excerpt_length=240){ if(! $post) $post = get_post(); $post_excerpt = $post->post_excerpt; if($post_excerpt == ''){ = mb_strimwidth($post_content,0,$excerpt_length,'…','utf-8'); } $post_excerpt = wp_strip_all_tags ( $post_excerpt ); $post_excerpt = trim( preg_replace( "/[\n\r\t ]+/", ' ', $post_excerpt ), ' '

    78120编辑于 2023-04-15
  • 来自专栏老高的技术博客

    WordPress首页文章不显示全文的方法

    解决办法有三种: more标签 自己写方法截取文字 the_excerpt() more标签 以下引用sumile_ting 的话: 这种方法是在每次写文章时在文章中插入一个More标签。 的the_content()修改为the_excerpt() 在function下加入以下代码 function custom_excerpt_length( $length ) { return 200; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); 给readmore加个链接,同样在functions.php中添加 : function new_excerpt_more( $more ) { return '阅读全文'; } add_filter('excerpt_more', 'new_excerpt_more'); 完美解决 参考: http://sumile.blog.hexun.com

    1.1K30编辑于 2022-12-27
  • 来自专栏私人订制

    Emlog文章页加入新的参数并写入数据库

    ' => $row['excerpt'], 下面插入 'sheli01' => $row['sheli01'], 前台直接调用:<? (); var author = $("#author").val(); var content = $('#content').val(); var excerpt = $('#excerpt').val(); var tag = $.trim($("#tag").val()); var top = $("#post_options "y" : ishide; var querystr = "content="+encodeURIComponent(content) +"&excerpt = $('#excerpt').val(); var tag = $.trim($("#tag").val()); var top = $("#post_options

    55520编辑于 2023-05-10
  • 来自专栏Django中文社区

    Django 博客文章自动生成摘要的两种方法

    body = models.TextField() excerpt = models.CharField(max_length=200, blank=True) 其中 body 字段存储的是正文 ,excerpt 字段用于存储摘要。 通过复写模型的 save 方法,在数据被保存到数据库前,先从 body 字段摘取 N 个字符保存到 excerpt 字段中,从而实现自动摘要的目的。 body = models.TextField() excerpt = models.CharField(max_length=200, blank=True) # 其它方法... def save(self, *args, **kwargs): # 从 body 摘取前 54 个字符赋给到 excerpt self.excerpt = self.body

    1K111发布于 2018-04-17
  • 来自专栏载润札记

    Twentytwelve主题文章设置摘要

    php // Add 140x140 image size add_image_size('excerpt-thumbnail', 140, 140, true); // Remove the ... from excerpt and change the text function change_excerpt_more() { function new_excerpt_more($more) { '">继续阅读»'; } add_filter('excerpt_more', 'new_excerpt_more'); } add_action('after_setup_theme ', 'change_excerpt_more');

    58010编辑于 2022-10-25
  • 来自专栏私人订制

    在文章页中显示摘要的方法 可用做文章页描述

    description) ”,以下是解决方法: 1、在根目录include/model/log_model.php(大概在124行)找到 'template' => $row['template'], 在后面加入 'excerpt ' => $row['excerpt'], 2、然后在echo_log.php中你需要调用的地方加入 <? php echo $excerpt; ? include/controller中的(大概86行) $site_description = extractHtmlData($log_content, 90); 把其中的log_content改为excerpt 即可,其中的90为字符数,如果不需要截取和清除格式,请直接把上的代码改为 $site_description = $excerpt;

    1.6K10编辑于 2023-05-10
  • 来自专栏HelloGitHub

    第 11 篇:自动生成文章摘要

    作者:HelloGitHub-追梦人物 博客文章的模型有一个 excerpt 字段,这个字段用于存储文章的摘要。目前为止,还只能在 django admin 后台手动为文章输入摘要。 body = models.TextField() excerpt = models.CharField(max_length=200, blank=True) def save 通过覆写模型的 save 方法,在数据被保存到数据库前,先从 body 字段摘取 N 个字符保存到 excerpt 字段中,从而实现自动摘要的目的。 body = models.TextField() excerpt = models.CharField(max_length=200, blank=True) # 其它方法.

    {{ post.excerpt }}...

    1.1K40发布于 2021-05-14
  • 来自专栏Django中文社区

    自动生成文章摘要

    博客文章的模型有一个 excerpt 字段,这个字段用于存储文章的摘要。目前为止,还只能在 Django Admin 后台手动为文章输入摘要。 ,excerpt 字段用于存储摘要。 通过复写模型的 save 方法,在数据被保存到数据库前,先从 body 字段摘取 N 个字符保存到 excerpt 字段中,从而实现自动摘要的目的。

    {{ post.excerpt }}... 总结 本章节的代码位于:Step17: generate excerpt automatically。 如果遇到问题,请通过下面的方式寻求帮助。 在下方评论区留言。

    2K80发布于 2018-04-17
  • 来自专栏沈唁志

    纯代码实现熊掌号H5页面结构化改造

    ($len=220){ if ( is_single() || is_page() ){ global $post; if ($post->post_excerpt) { $excerpt = $post->post_excerpt; } else { if(preg_match('/

    (.*)<\/p>/iU',trim(strip_tags($post->post_content, = explode("\n",trim(strip_tags($post->post_content))); $post_content = $post_content_r['0']; } $excerpt *#s','$1',$post_content); } return str_replace(array("\r\n", "\r", "\n"), "", $excerpt); } } //优先获取文章中的三张图 '", "images": ["'.fanly_post_imgs().'"], "description": "'.fanly_excerpt().

    92220发布于 2018-05-24
  • 来自专栏ytkah

    给WordPress Page页面添加摘要输入框

    默认情况下 WordPress Page 编辑页面没有摘要(Excerpt)输入框,所以对 WordPress 进行 SEO 的时候比较麻烦。 这个时候我们就可以通过以下代码给我 WordPress Page 添加摘要输入框: add_action( 'admin_menu', 'my_page_excerpt_meta_box' ); function my_page_excerpt_meta_box() { add_meta_box( 'postexcerpt', __('Excerpt'), 'post_excerpt_meta_box'

    71210编辑于 2022-03-14
  • 来自专栏若志随笔

    Typecho实现相册.书单页面自定义

    NULL, _t('相册名称'), _t('输入相册的缩略名')); $layout->addItem($photos_name);/** 自定义每一个相册的缩略名 */ $photos_excerpt = new Typecho_Widget_Helper_Form_Element_Text('photos_excerpt', NULL, NULL, _t('相册介绍'), _t('输入相册的介绍' , NULL, _t('书的出版时间'), _t('输入书的出版时间')); $layout->addItem($books_time);/** 输出书的出版时间 */ $books_excerpt = new Typecho_Widget_Helper_Form_Element_Text('books_excerpt', NULL, NULL, _t('书的介绍'), _t('输入书的介绍')) 输出阅读进度 */ } 通过以上代码可整理出各个自定义字段为: article_type//文章类型自定义 photos_name//文章缩略名自定义 books_time//书的出版时间 books_excerpt

    1.4K20编辑于 2021-12-23
  • 来自专栏阳光之海

    WordPress实现熊掌号H5页面结构化改造

    页面改造最重要的其实就是添加 JSON_LD 数据了,其实可以用下面的代码来实现: //获取文章/页面摘要 function fanly_excerpt($len=220){ if ( is_single () || is_page() ){         global $post; if ($post->post_excerpt) {             $excerpt  = $post->post_excerpt ->post_content)));                 $post_content = $post_content_r['0'];             }             $excerpt *#s','$1',$post_content);         } return str_replace(array("\r\n", "\r", "\n"), "", $excerpt);      '", "images": ["'.fanly_post_imgs().'"], "description": "'.fanly_excerpt().

    57830发布于 2018-10-31
  • 来自专栏私人订制

    Emlog教程 - 侧边栏最新文章获取图片、分类、摘要等

    empty($row['excerpt']) ? $row['excerpt'] : ''.$row['content'].''; if (! empty($row['excerpt'])){preg_match_all("/\<img.*?src\=\"(.*?) \"[^>]*>/i", $row['excerpt'], $match); if(empty($match[1][0])) { preg_match_all("/\<img.*? empty($row['excerpt']) ? $row['excerpt'] :''.$row['content'].''; if (! empty($row['excerpt'])){preg_match_all("/\<img.*?src\=\"(.*?)

    44210编辑于 2023-05-10
  • 来自专栏WordPress果酱

    WordPress 技巧:给 WordPress Page 添加摘要输入框

    我一般是使用 WordPress 的摘要直接作为 Meta Description 进行 SEO,但是默认情况下 WordPress Page 编辑页面没有摘要(Excerpt)输入框,所以对 WordPress 这个时候我们就可以通过以下代码给我 WordPress Page 添加摘要输入框: add_action( 'admin_menu', 'my_page_excerpt_meta_box' ); function my_page_excerpt_meta_box() { add_meta_box( 'postexcerpt', __('Excerpt'), 'post_excerpt_meta_box

    53620编辑于 2023-04-15
  • 来自专栏私人订制

    Emlog非插件实现投稿功能

    addslashes(trim($_POST['text'])) : ''; $excerpt = isset($_POST['excerpt']) ? addslashes(trim($_POST['excerpt'])) : ''; $tags = isset($_POST['tags']) ? = mysql_query("select title from emlog_blog where excerpt='$excerpt' limit 1"); if(empty($title) || empty($excerpt) && preg_match("/^[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\’:+!] *([^<>\"])*$/",$excerpt) == false){emMsg('提交失败:原文地址出错,可能以下原因造成
    1、是否加了http://
    2、网址格式是否正确

    57320编辑于 2023-05-10
  • 来自专栏EdisonTalk

    轻量级ORM框架初探-Dapper与PetaPoco的基本使用

    VARCHAR(120) NOT NULL, [Title] NVARCHAR(100) NOT NULL, [Published] DATETIME NOT NULL, [Excerpt Slug VARCHAR(120) NOT NULL, Title NVARCHAR(100) NOT NULL, Published DATETIME NOT NULL, Excerpt new Post() { CategoryId = 10, Slug = "BOOK", Title = "大话数据结构", Published = DateTime.Now.AddDays(1), Excerpt Post() { CategoryId = 10, Slug = "BOOK", Title = "构建之法-现代软件工程", Published = DateTime.Now.AddDays(1), Excerpt ; count = connection.Execute("insert into Posts values(@CategoryId, @Slug, @Title, @Published, @Excerpt

    2.2K30发布于 2018-08-20
  • 来自专栏WordPress技术文章

    为wordpress顶部header.php文件中调用不同的标题和摘要

    ''; // 显示文章标题 echo '

    ' . get_the_excerpt() . ''; // 显示页面标题 echo '

    ' . get_the_excerpt() . 文章页(is_single()):显示文章标题(get_the_title())和文章摘要(get_the_excerpt())。 页面(is_page()):显示页面标题(get_the_title())和页面摘要(get_the_excerpt())。其他页面:显示网站标题并加链接(home_url(‘/’))。 注意事项:确保你的主题支持摘要功能(get_the_excerpt()),否则可能需要手动添加摘要。如果你的主题有自定义的标题或描述字段,可能需要调整代码以适配这些字段。

    27900编辑于 2025-08-10
  • 来自专栏老蒋专栏

    美化大前端DUX主题 - 新发布的文章加上NEW图标

    第一、修改主题的excerpt.php 找到主题目录中的excerpt.php文件,然后找到对应代码: echo '

    <a'. "new-icon">New';} else{echo "";} 第二、修改样式 找到样式文件:main.css,在最后添加: /** 修改NEW标志样式 itbulu.com */ .excerpt { positiON: relative; } /** NEW 图标文字版样式 **/ .excerpt .new-icon{ position: absolute; right: -38px; top

    90830编辑于 2021-12-27
  • 来自专栏WordPress果酱

    我是如何 SEO WordPress 的 2:Description 和 Keywords

    WordPress 在撰写日志的时候,可以给日志添加摘要(excerpt)和标签(tag),我的做法就是,就如给日志添加了摘要就把摘要做为 Description,如果没有设置摘要的话,则截取文章的前 ; $keywords = "WordPress, 博客, 互联网, 主题, 插件"; } elseif (is_single()){ if ($post->post_excerpt) { $description = $post->post_excerpt; } else { $description = substr(strip_tags

    60630编辑于 2023-04-15
领券