在特定页面ID上应用WordPress功能

我想将以下功能应用于三个特定的Woocommerce类别页面。例如(cat-a, cat-b, cat-c)我可以通过Page ID, Slug或某种方式寻址它们吗?

function remove_some_widgets(){
    unregister_sidebar( 'shop-sidebar' );
}
add_action( 'widgets_init', 'remove_some_widgets', 11 );

#1


使用ispage()

function remove_some_widgets(){
    if(is_page()){
        unregister_sidebar( 'shop-sidebar' );
    }
}
add_action( 'widgets_init', 'remove_some_widgets', 11 );

如上所述, 这将不会应用任何单个页面。你可以根据需要向is_page()添加参数:

//显示任何单个页面时。 is_page();

//当显示第42页(ID)时。 is_page(42);

//当显示post_title为” Contact”的页面时。 is_page(‘Contact’);

//当显示post_name(子句)为” about-me”的页面时。 is_page(‘about-me’);

is_page()

来源:

https://www.srcmini02.com/62832.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37736.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?