最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

code block does not show in excerpt

programmeradmin2浏览0评论

I am creating some blog pages with example codes, and I would like to show the codes in excerpts, but WordPress automatically excludes code blocks from excerpts, is there a workaround for showing code blocks in the excerpt?

I am creating some blog pages with example codes, and I would like to show the codes in excerpts, but WordPress automatically excludes code blocks from excerpts, is there a workaround for showing code blocks in the excerpt?

Share Improve this question asked Mar 4, 2022 at 9:34 Botond VajnaBotond Vajna 4714 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try getting it in raw form from the DB:

global $wpdb;
$post_excerpt = $wpdb->get_var(
        $wpdb->prepare(
            "SELECT post_excerpt FROM $wpdb->posts
             WHERE ID = %d
            ",
            $post->ID
        )
    );

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论