Написал такой код:
add_shortcode ('woo_fav_counter', 'woo_fav_counter' );
function woo_fav_counter() {
ob_start();
global $woocommerce;
$cart_count = $woocommerce->cart->cart_contents_count; // Set variable for cart item count
?>
<?php
if ( $woocommerce->cart->cart_contents_count <= 0 ) {
?>
<link rel="icon" href="https://docti-posture.com/wp-content/uploads/2020/09/cropped-favicon-32x32.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 1 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-A33W.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 2 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-4UZ5.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 3 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-DGVGA.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 4 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-V3ZP.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 5 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-KW6U8.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 6 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-VL5Q.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 7 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-PP46.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 8 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-SAY9.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count == 9 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-9OXOJ.png" type="image/x-icon">
<?php
}
else if ( $woocommerce->cart->cart_contents_count >= 10 ) {
?>
<link rel="icon" href="https://wmpics.pics/di-987A.png" type="image/x-icon">
<?php
}
?>
<?php
return ob_get_clean();
}
для измение фавикон, взависимоти от количевства товаров в корзине, в коде та изменяется ссылка на фавикон, а вот всё равно всё время с одним товаром. В чём проблема?