50个WordPress过滤钩子(介绍过滤钩子)

WordPress 过滤钩子是 WordPress 核心代码中的一种机制,它允许开发者在特定事件发生时插入自定义代码,这些事件可以是用户登录、发布文章、编辑页面等等,通过使用过滤钩子,开发者可以在不修改 WordPress 核心代码的情况下,对 WordPress 的行为进行定制。

以下是一些常见的 WordPress 过滤钩子:

50个WordPress过滤钩子(介绍过滤钩子)

1、pre_get_posts:在查询文章之前触发。

2、the_posts:在查询到的文章列表中显示文章之前触发。

3、the_title:在显示文章标题之前触发。

4、the_content:在显示文章内容之前触发。

5、the_excerpt:在显示文章摘要之前触发。

6、wp_head:在页面头部输出之前触发。

7、wp_footer:在页面底部输出之前触发。

8、wp_enqueue_scripts:在加载 JavaScript 和 CSS 文件之前触发。

9、admin_enqueue_scripts:在后台加载 JavaScript 和 CSS 文件之前触发。

10、login_enqueue_scripts:在登录页面加载 JavaScript 和 CSS 文件之前触发。

11、admin_menu:在添加或删除菜单项之前触发。

12、admin_init:在初始化 admin 时触发。

13、admin_notices:在显示管理员通知之前触发。

14、admin_print_styles-edit.css:在编辑主题样式表时触发。

15、admin_print_styles-[custom].css:在编辑自定义样式表时触发。

16、admin_print_styles-[theme].css:在编辑主题样式表时触发。

17、admin_print_scripts-edit.js:在编辑主题脚本时触发。

50个WordPress过滤钩子(介绍过滤钩子)

18、admin_print_scripts-[custom].js:在编辑自定义脚本时触发。

19、admin_print_scripts-[theme].js:在编辑主题脚本时触发。

20、admin_footer-edit.php:在编辑主题页脚时触发。

21、admin_footer-[custom].php:在编辑自定义页脚时触发。

22、admin_footer-[theme].php:在编辑主题页脚时触发。

23、admin_bar_menu:在 admin bar 上添加或删除菜单项之前触发。

24、wpseo_frontend_noindex:在前端禁用 SEO 索引功能之前触发。

25、wpseo_frontend_metabox:在前端显示 SEO 元框之前触发。

26、wpseo_frontend_breadcrumbs:在前端显示 SEO 面包屑导航之前触发。

27、wpseo_frontend_robots_nofollow:在前端禁用 SEO 机器人 nofollow 功能之前触发。

28、wpseo_frontend_sitemaps:在前端显示 SEO sitemap 链接之前触发。

29、wpseo_frontend_sociallinks:在前端显示 SEO social links 链接之前触发。

30、wpseo_frontend_opengraph:在前端显示 OpenGraph 标签之前触发。

31、wpseo_frontend_twittercards:在前端显示 TwitterCards 标签之前触发。

32、wpseo_frontend_json+ld:在前端显示 JSON-LD 标签之前触发。

33、wpseo_frontend_pagination:在前端显示分页链接之前触发。

34、wpseo_frontend_canonical:在前端显示规范 URL 链接之前触发。

50个WordPress过滤钩子(介绍过滤钩子)

35、wpseo_frontend_alternate'hreflang'attributes:在前端显示 hreflang 属性链接之前触发。

36、wpseo_frontend'prerender'filter:在前端预渲染页面内容之前触发。

37、wpseo_frontend'canonical'filter:在前端设置规范 URL 之后触发。

38、wpseo_frontend'og:image'filter:在前端设置 OpenGraph image URL 之后触发。

39、wpseo_frontend'twitter:image'filter:在前端设置 Twitter Card image URL 之后触发。

40、wpseo_frontend'twitter:site'filter:在前端设置 Twitter Card site URL 之后触发。

41、wpseo_frontend'twitter:creator'filter:在前端设置 Twitter Card creator handle URL 之后触发。

42、wpseo_frontend'twitter:card'filter:在前端设置 Twitter Card type URL 之后触发。

43、wpseo_frontend'googlebot'filter:在前端设置 Googlebot user agent URL 之后触发。

44、wpseo_frontend'bingbot'filter:在前端设置 Bingbot user agent URL 之后触发。

45、wpseo_frontend'yandex'filter:在前端设置 YandexBot user agent URL 之后触发。

46、wpseo_frontend'facebook'filter:在前端设置 Facebook scraper user agent URL 之后触发。

47、wpseo_frontend'always'filter:在所有其他过滤器之后,但在输出任何内容之前触发。

48、wpseo_frontend'after'filter:在所有其他过滤器之后,但在输出任何内容之前(与 always filter 相同)触发。

49、wpseo_frontend'before'filter:在所有其他过滤器之前,但在输出任何内容之前(与 always filter 相同)

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/247843.html

(0)
K-seoK-seoSEO优化员
上一篇 2024年1月23日 02:44
下一篇 2024年1月23日 02:45

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入