в вопросе написано про return
Где ошибка в do_action?
Что не так при вставке в тег div, пробовал echo и return, все равно не вставляется.
function one() { echo 1; }
function two() { echo 2; }
function three() { echo 3; }
add_action( 'foo', 'one' );
add_action( 'foo', 'two' );
add_action( 'foo', 'three' );
echo '<div id="fff">';
do_action( 'foo' );
echo '</div>';
Если сделаете через apply_filters все будет корректно...
function plus_foo($value){
return $value;
}
add_filter( 'foo', 'plus_foo' );
echo '<div id="fff">'.apply_filters('plus_foo',123).'</div>';
Это я понимаю, но как сделать так, чтобы не писать стиль, а ограничиться class="aaa"
add_action('wp_head','my_style');
if(!function_exists('my_style')){
function my_style(){?>
<style id="my_style" type="text/css">
.aaa{background-image: url(<?php echo get_the_post_thumbnail_url(); ?>);}
</style><?php }}
add_theme_support('post-thumbnails');
register_post_type....
...'supports'=>array('thumbnail',...
<link rel="preload" as="style" onload="this.rel='stylesheet'"
ибо не работает как надоonload="this.rel='stylesheet'"
? Событие onload используется как указатель, что веб-страница полностью загружена, включая содержание, изображения, стилевые файлы и внешние скрипты.
//для taxonomy-{taxonomy}-{term}.php taxonomy-{taxonomy}.php и search.php
add_filter('pre_get_posts','add_tax_in_arhive');
if(!function_exists('add_tax_in_arhive')){
function add_tax_in_arhive($query){
if(!is_admin()){
if($query->is_tax('Ваша таксономия')&&$query->is_main_query()){
$terms=get_terms('Ваша таксономия',array('fields'=>'ids'));
$query->set('post_type',array('Ваш тип поста'));
$query->set('tax_query',array('relation' =>'OR',array('taxonomy'=>'Ваша таксономия','field'=>'id','terms'=>$terms,'operator'=>'NOT IN')));
$query->set('posts_per_page','2');
}if($query->is_search){$query->set('post_type',array('post','page','Ваш тип поста'));}return $query;}}}
if(!function_exists('VAB_add_async_attribute')){function VAB_add_async_attribute($tag,$handle){
$handles=array('tabs','click','lightbox','fresco','RadiVo');
foreach($handles as $defer_script){if($defer_script===$handle){return str_replace('src','async="async" src',$tag);}}return $tag;}}
add_filter('script_loader_tag','VAB_add_async_attribute',10,2);
<link rel="preload prefetch" as="style" onload="this.onload=null;this.rel='stylesheet'".......
if(!function_exists('add_rel_attribute_style')){function add_rel_attribute_style($tag,$handle){
$handles=array('mydashicons');
foreach($handles as $defer_script){if($defer_script===$handle){
return str_replace('rel','rel="preload prefetch" as="style" onload="this.onload=null;this.rel=\'stylesheet\'" rel',$tag);
}}return $tag;}}
add_filter('style_loader_tag','add_rel_attribute_style',10,2);
add_action('customize_controls_enqueue_scripts',
и написать свой тригер или подобное для Вашего
правда это, если в настройках
'transport'=>'postMessage'
в целом без postMessage должно работать например: