samedi 26 mars 2016

Woocommerce add images from folder to featured product image

  <ul class="products">
      <?php
        $args = array(
          'post_type' => 'product',
          'posts_per_page' => 100
          );
        $loop = new WP_Query( $args );
        if ( $loop->have_posts() ) {
          while ( $loop->have_posts() ) : $loop->the_post();
          global $product;
          // echo '<pre>';
          // print_r($product->id);
          // echo '</pre>';
          ?>
          <img src="<?php echo bloginfo('template_url'); ?>/images/<?php echo $product->id; ?>_1.jpg" alt="zzz" />
          <?php
          //  wc_get_template_part( 'content', 'product' );
          endwhile;
        } else {
          echo __( 'No products found' );
        }
        wp_reset_postdata();
      ?>
      </ul><!--/.products-->

Hi, I have a old folder with product images, there are about 200 of them, each image has the ID the same as the product, and the category next to it, exemple 301_1.jpg, and the product ID is 301. I need to add the images from the folder to the products more exactly featured image. How can I do that ?input the images into a database ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire