我需要将与“pretty\\u photo”相关的样式和脚本从我的主题中移出或删除,但只有在called or needed
我的functions.php
wp_enqueue_style(\'pretty_photo\', MASTER_THEME_DIR . \'/addons/prettyphoto/prettyPhoto.css\',array() ,false,\'all\')
我需要将与“pretty\\u photo”相关的样式和脚本从我的主题中移出或删除,但只有在called or needed
我的functions.php
wp_enqueue_style(\'pretty_photo\', MASTER_THEME_DIR . \'/addons/prettyphoto/prettyPhoto.css\',array() ,false,\'all\')
我终于开始工作了。。代码为:
add_action( \'wp_enqueue_scripts\', \'pretty_photo_styles\', 100 );
function pretty_photo_styles() {
if ( ! is_single() ) {
wp_dequeue_script( \'pretty_photo\' );
wp_dequeue_style( \'pretty_photo\' );
}
}
如果我遗漏了什么,请有人纠正!我试过了,它对我有效。首先,破解主题通常是个坏主意,除非它是您构建和维护的主题。我不知道这是否适用于你。
听起来,您只需要在单个帖子页面上加载该代码。从技术上讲,这应该相当简单。这个is_singular()
模板标记应该可以做到这一点。
function conditionally_load_style_wpse_143224() {
if (is_singular()) {
wp_enqueue_style(
\'pretty_photo\',
MASTER_THEME_DIR . \'/addons/prettyphoto/prettyPhoto.css\',
array(),
false,
\'all\'
);
}
}
add_action(\'wp_enqueue_scripts\',\'conditionally_load_style_wpse_143224\');
What I want: 通过创建$query = new WP_Query($args);Why: 以json格式返回特定内容,作为一种API请求,准备在另一个站点上显示What I tried first:foreach($query->posts as $post) { $post->post_content = apply_filters(\'the_content\', $post->post_content); }; 这执行了autop 和do