Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@kawamurayuto

WordPress the_content で本文が展開される前または後にフィルターをかけるには

More than 5 years have passed since last update.

記事本文を加工・解析したい場合は the_content に対してフィルターをかけます。

優先度を設定せずに (デフォルト $priority = 10 ) ただ普通にかけた場合は、下記ファイル内に定義されているように、本文内のショートコードが展開される前に実行されてしまうので

wp-includes/default-filters.php
// Shortcodes
add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop()

展開後にフィルターをかけたい場合は

add_filter('the_content', 'the_content_after_filter', 12);

のように設定します。

ちなみに展開前にフィルターをかける前は

add_filter('the_content', 'the_content_before_filter', 10); // 第三引数は省略しても同じ

のように設定します。

3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kawamurayuto
自分の通った道が、誰かの役に立てば幸いです( ・ิω・ิ)

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?