admin管理员组文章数量:1130349
Trying to remove dashicons for non-logged in users excluding specific pages and specific categories with the following:
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
if ( !is_page( array( 9, 10 ) ) || !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
}
The code works if I do not use the OR condition. In other words it works if I apply a sole IF statement either for the specific pages or for the specific categories. It doesn’t work if I use both IF statements under the OR condition. Which is the correction needed?
Trying to remove dashicons for non-logged in users excluding specific pages and specific categories with the following:
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
if ( !is_page( array( 9, 10 ) ) || !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
}
The code works if I do not use the OR condition. In other words it works if I apply a sole IF statement either for the specific pages or for the specific categories. It doesn’t work if I use both IF statements under the OR condition. Which is the correction needed?
Share Improve this question edited Jan 9, 2019 at 18:57 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Jan 9, 2019 at 17:10 MichaelMichael 32 silver badges5 bronze badges1 Answer
Reset to default 0Try this.
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() && !is_page( array( 9, 10 ) ) && !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
I basically just combined the IF statements and changed || to &&.
Trying to remove dashicons for non-logged in users excluding specific pages and specific categories with the following:
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
if ( !is_page( array( 9, 10 ) ) || !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
}
The code works if I do not use the OR condition. In other words it works if I apply a sole IF statement either for the specific pages or for the specific categories. It doesn’t work if I use both IF statements under the OR condition. Which is the correction needed?
Trying to remove dashicons for non-logged in users excluding specific pages and specific categories with the following:
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() ) {
if ( !is_page( array( 9, 10 ) ) || !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
}
The code works if I do not use the OR condition. In other words it works if I apply a sole IF statement either for the specific pages or for the specific categories. It doesn’t work if I use both IF statements under the OR condition. Which is the correction needed?
Share Improve this question edited Jan 9, 2019 at 18:57 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Jan 9, 2019 at 17:10 MichaelMichael 32 silver badges5 bronze badges1 Answer
Reset to default 0Try this.
add_action( 'wp_enqueue_scripts', 'go_dequeue_dashicons' );
function go_dequeue_dashicons() {
if ( ! is_user_logged_in() && !is_page( array( 9, 10 ) ) && !in_category( array( 29, 2 ) ) ) {
wp_deregister_style( 'dashicons' );
}
}
I basically just combined the IF statements and changed || to &&.
本文标签: Remove dashiconsmincss conditionally
版权声明:本文标题:Remove dashicons.min.css conditionally 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749025330a2305014.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论