在标题中使用 WordPress 简码 [英] Using WordPress shortcode in a title

查看:43
本文介绍了在标题中使用 WordPress 简码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些可以在 WordPress 帖子或页面中正常工作的短代码.有什么我可以添加到 functions.php 以使短代码能够在 WordPress 帖子标题中工作的内容吗?

I have some shortcodes which work fine inside a WordPress post or page. Is there anything I can add to functions.php to enable a shortcode to work inside a WordPress post title?

推荐答案

您可以尝试在 functions.php 文件中的标题中添加过滤器,例如:

You could try adding a filter to the title in the functions.php file such as:

add_filter( 'the_title', 'do_shortcode' );

似乎对我有用,但是它可能会对您的永久链接造成严重破坏,我不推荐它.

Seems to work for me, however it may play havoc with your permalink's and I wouldn't recommend it.

将来与 WordPress 相关的问题可能会更好地针对 https://wordpress.stackexchange.com/.

In future WordPress related questions might be better directed at https://wordpress.stackexchange.com/.

这篇关于在标题中使用 WordPress 简码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆