global $post;
if ( is_single() && ! is_admin() && ($post->ID != 5)) ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
global $post;
$without_ad = [1,4,6,7]
if ( is_single() && ! is_admin() && !in_array($post->ID, $without_ad)) ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
global $post;
if ( is_single() && ! is_admin() && !in_category($cat_id, $post)) ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 10);
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 20);
/**
* Cart Fragments.
*
* Ensure cart contents update when products are added to the cart via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX.
*/
function my_woocommerce_cart_link_fragment( $fragments ) {
ob_start();
my_woocommerce_cart_link();
$fragments['#header-cart-contents'] = ob_get_clean();
return $fragments;
}
}
add_filter( 'woocommerce_add_to_cart_fragments', 'my_woocommerce_cart_link_fragment' );
/**
* Cart Link.
*
* Displayed a link to the cart including the number of items present and the cart total.
*
* @return void
*/
function my_woocommerce_cart_link() {
?>
<div id="header-cart-contents" class="header-cart">
<span><?= wp_kses_data( WC()->cart->get_cart_contents_count());?></span>
<a href="<?php echo esc_url( wc_get_cart_url() ); ?>"><img src="<?= get_template_directory_uri();?>/img/header-cart.png" alt="shop-cart"></a>
</div>
<?php
}
}
my_woocommerce_cart_link();
$fragments['#header-cart-contents'] = ob_get_clean();
Обязательно был верный селектор вашего блока с корзинойadd_action('wp_enqueue_scripts', 'champfood_enqueue_styles');
Вопрос в том, какие могут появиться неприятности, если я все делал через записи?
get_header(); ?>
<div class="background-type-2">
<div class="main-content">
<div class="line-ver">
<div class="wrapper">
<?php get_sidebar('blog'); ?>
<div id="container">
<div id="content" class="blog" role="main">
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>"<?php post_class(); ?>>
<div class="post_headline">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
</div>
<div class="post-exp">
<?php the_excerpt(); ?>
</div>
<div class="tags">
<?php var_dump(get_the_terms( $post->id, 'post_tag' ));?>
</div>
</article>
<?php endwhile;
if (function_exists('custom_pagination')) {
custom_pagination($query->max_num_pages,"",$paged);
}
endif;
?>
</div><!-- #content -->
</div><!-- #container -->
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
while(have_posts()) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post_headline">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
</div>
</article>
<?php
endwhile;
the_posts_pagination();