0

我尝试在我网站的产品缩略图中添加 Feed 广告

没有错误,网站运行正常。但是我的网站上没有出现任何广告。如何在 WooCommerce 产品缩略图中的提要广告中实现这一点。

我已将 woocommerce-teplate.php 编辑为

    if ( ! function_exists( 'woocommerce_content' ) ) {

    /**
     * Output WooCommerce content.
     *
     * This function is only used in the optional 'woocommerce.php' template.
     * which people can add to their themes to add basic woocommerce support.
     * without hooks or modifying core templates.
     */
  function woocommerce_content() {
        $i=1;
        if ( is_singular( 'product' ) ) {

            while ( have_posts() ) :
                the_post();

                                if($i==5||$i==7||$i==10){?>
                                 #my adsense code
                                <?php }

                wc_get_template_part( 'content', 'single-product' );
            $i++;
            endwhile;

        } else {
            ?>

            <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

                <h1 class="page-title"><?php woocommerce_page_title(); ?></h1>

            <?php endif; ?>

            <?php do_action( 'woocommerce_archive_description' ); ?>

            <?php if ( woocommerce_product_loop() ) : ?>

                <?php do_action( 'woocommerce_before_shop_loop' ); ?>

                <?php woocommerce_product_loop_start(); ?>

                <?php if ( wc_get_loop_prop( 'total' ) ) : ?>
                    <?php $i++;  while ( have_posts() ) : ?>
                        <?php the_post(); ?>

                        <?php  if($i==5||$i==7||$i==10){?>
                          #my adsense code
                        <?php }?>

                        <?php wc_get_template_part( 'content', 'product' ); ?>
                    <?php $i++;?>
                    <?php endwhile; ?>
4

0 回答 0