WP 通过 function.php 中的 post id 执行带有例外的简码
WP execute shortcode with exeptions via post id in function.php
我在下面有这个功能可以在我的 Wordpress posts 上执行一个简码。
到目前为止效果很好。
现在我想通过此函数的 post ID 排除一些 posts。
例如,我想排除 ID 为 187 的 post 和 ID 为 173 的 post。
最简单的方法是什么? PHP 真的不是我的强项。
举个例子就好了。
谢谢
托尼
// Add shortcode on posts
add_action( 'genesis_before_content', 'execute_shortcode', 15 );
add_action( 'genesis_entry_footer', 'execute_shortcode', 15 );
function execute_shortcode() {
if(is_single())
echo do_shortcode( '[banner1]' );
}
如果条件 about 是单一的,您可以添加。
https://developer.wordpress.org/reference/functions/is_single/
If(is_single() && !is_single(your_id)){
我在下面有这个功能可以在我的 Wordpress posts 上执行一个简码。 到目前为止效果很好。
现在我想通过此函数的 post ID 排除一些 posts。 例如,我想排除 ID 为 187 的 post 和 ID 为 173 的 post。
最简单的方法是什么? PHP 真的不是我的强项。 举个例子就好了。
谢谢 托尼
// Add shortcode on posts
add_action( 'genesis_before_content', 'execute_shortcode', 15 );
add_action( 'genesis_entry_footer', 'execute_shortcode', 15 );
function execute_shortcode() {
if(is_single())
echo do_shortcode( '[banner1]' );
}
如果条件 about 是单一的,您可以添加。 https://developer.wordpress.org/reference/functions/is_single/
If(is_single() && !is_single(your_id)){