How to add in WP_Query to every 3 posts displayed? [duplicate]

This would work: <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 8, ‘orderby’ => ‘date’, ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { $i=1; echo ‘<ul>’; while ( $loop->have_posts() ) : $loop->the_post(); //wc_get_template_part( ‘content’, ‘product’ ); ?> <li class=”col-md-3″> <div class=”gridproduto”> <a href=”https://wordpress.stackexchange.com/questions/266104/<?php the_permalink(); ?>”> <?php global $post, $product; ?> … Read more

How to restrict type/size of file uploads in any plugin?

You use upload_mimes filter to restrict the image type as : add_filter(‘upload_mimes’,’restict_image_type’); function restict_image_type($mimes) { $mimes = array( ‘jpg|jpeg|jpe’ => ‘image/jpeg’, ‘gif’ => ‘image/gif’, ‘png’ => ‘image/png’, ); return $mimes; } For upload limit you can set in .htaccess one of the following; LimitRequestBody 1048576 //( 1MB) php_value upload_max_filesize 1M php_value post_max_size 1M

Use PHP code in Menu Admin Section

Allan, thanks for clarifying the question. You can’t add PHP in the wp-admin menu manager. Instead, here is a way to keep the menu dynamic and managed in wp-admin, while still allowing you to add your PHP at the end: <?php $args = array( ‘menu’ => ‘your-menu-name’, ‘container’ => ”, ‘items_wrap’ => ‘%3$s’ ); ?> … Read more

how add css class to product boxes li, for img, add cart button, decs, price… [closed]

You don’t need to add class to those elements. You can apply CSS style to those elements by using following selectors respectively. .post-type-archive-product ul.products li.product .post-type-archive-product ul.products li img .post-type-archive-product ul.products li .button .post-type-archive-product ul.products li .woocommerce-loop-product__title .post-type-archive-product ul.products li span.woocommerce-Price-amount.amount

How to get the WooCommercer product variation image

here is product set in display in cart in cart.php $_product = apply_filters( ‘woocommerce_cart_item_product’, $cart_item[‘data’], $cart_item, $cart_item_key ); $product_id = apply_filters( ‘woocommerce_cart_item_product_id’, $cart_item[‘product_id’], $cart_item, $cart_item_key ); $thumbnail = apply_filters( ‘woocommerce_cart_item_thumbnail’, $_product->get_image(), $cart_item, $cart_item_key ); if ( ! $_product->is_visible() ) { echo $thumbnail; } else { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($_product->id), ‘thumbnail’ ); $cartimgsrc=UNAVAILABLEIMG; if($thumb[0]){ $cartimgsrc=$thumb[0]; $product … Read more

Admin Order adding an extra product on add_line_item

So i manage to solve the problem myself after looking little more around, the hook is super poorly named. But it does the trick! It fires after the order is created, so you can manipulate the order as you wish. add_action(‘woocommerce_process_shop_order_meta’, woocommerce_process_shop_order’, 10, 2); function woocommerce_process_shop_order ($post_id, $post) { global $woocommerce; $oOrder = new WC_Order($post_id); … Read more