add_filter( 'post_thumbnail_html', 'filter_function_name_9525', 10, 5 );
function filter_function_name_9525( $html, $post_id, $post_thumbnail_id, $size, $attr ){
$append = ('my_alt' == $attr['alt'] ? 'Yes!' : 'sorry, but no.');
$append = '<p>' . $append . '</p>';
return $html . '<p>' . $append . '</p>';
}
function tesp_menu_page_cb(){
?><h1>Плагин для тестирования функций</h1><?php
$id = 13;
$size = 'thumbnail';
$attr = array('alt' => 'my_alt' );
$thumbnail = get_the_post_thumbnail( $id, $size, $attr );
echo $thumbnail;
$attr = array('alt' => 'nothing' );
$thumbnail = get_the_post_thumbnail( $id, $size, $attr );
echo $thumbnail;
}
то ничего не работает.
add_filter('post_thumbnail_html', 'multi_format_thumbnail', 10, 5);
/**
* Filters the post thumbnail HTML.
*
* @since 2.9.0
*
* @param string $html The post thumbnail HTML.
* @param int $post_id The post ID.
* @param string $post_thumbnail_id The post thumbnail ID.
* @param string|array $size The post thumbnail size. Image size or array of width and height
* values (in that order). Default 'post-thumbnail'.
* @param string $attr Query string of attributes.
*/
function multi_format_thumbnail( $html, $post_id, $post_thumbnail_id, $size, $attr ){
};
/************************************************************************/
/* меняем текст кнопки у товара*/
add_filter( 'woocommerce_product_add_to_cart_text', 'pytex_woocommerce_product_add_to_cart_text', 99, 2 );
function pytex_woocommerce_product_add_to_cart_text($text, $product){
$out = $text;
if ( 'Подробнее' == $text) {
$out = 'Под заказ';
}
return $out;
echo json_encode($data_arr);
if ($a == count( $data_arr )) { $a = 0; }
if (have_posts()):
$a = 0;
$data_arr = array('one', 'two', 'three');
while (have_posts()) : the_post();
$img = get_the_post_thumbnail( get_the_ID(), 'large' );
// проверка на выход за пределы массива
if $a > count( $data_arr ){ $a = 0; }
$img = str_replace('<img', '<img data-slidr="'.$data_arr[$a].'"', $img);
$a++;
$slider.='<div><a href="'.get_permalink( $post->ID ).'">' . $img . '</a>';
if($up_options->nivo_settings_showSlideText == 'true') {
$slider .= '<div class="slide">
<h2 class="slidetitle"><a href="'.get_permalink( $post->ID ).'">'.get_the_title().'</a></h2>
<p class="slidetext">'.get_the_excerpt().'</p>
</div>';
}
$slider .= '</div>';
endwhile;
endif;
Может автор левша