Ich habe eine benutzerdefinierte Produkt-Schleife mit "WP_Query" erstellt, um Woocommerce Produktdaten in Tabelle anzuzeigen und es funktioniert gut. Aber 'posts_per_page' => -1,
zeigt nicht alle Produkte aus der Beispielkategorie an.Woocommerce Custom Produkt Loop Beitrag pro Seite Ausgabe
Momentan habe ich 17 Produkte in der Kategorie Probe. es zeigt nur 10 Produkte. Ich habe für das Problem überprüft und festgestellt, dass „WP_Query“ in Beiträgen so verwendet wird Es wird Wert des Eintrages von setiing pro Seite unter> Lesen> Blog-Seiten zeigen höchstens
Wie Ich kann 'posts_per_page' => -1 machen, um mehr als 10 Produkte zu verwenden, ohne die Einstellungen von Wordpress Post pro Seite zu ändern. Danke im Voraus. Folgendes ist mein vollständiger Code.
<?php // The args for the loop
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'sample' // Your category name here
)
),
'post_type' => 'product',
'orderby' => 'title',
); ?>
<?php
$loop = new WP_Query($args); // The Loop
if ($loop->have_posts()) {
while ($loop->have_posts()) : $loop->the_post(); ?>
<table> <!-- Fetching woocommerce data in table -->
<tr>
<td><?php the_content(); ?></td> <!-- Content -->
<td><?php the_title(); ?></td> <!-- Title -->
<td><?php echo ($sku = $product->get_sku()) ? $sku : __('N/A', 'woocommerce'); ?></td> <!-- SKU -->
<td><?php echo $product->get_price_html(); ?></td> <!-- Price -->
<td>
<?php global $product; // For Adding Add to Cart button in loop
echo apply_filters('woocommerce_loop_add_to_cart_link',
sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>',
esc_url($product->add_to_cart_url()),
esc_attr($product->id),
esc_attr($product->get_sku()),
$product->is_purchasable() ? 'add_to_cart_button' : '',
esc_attr($product->product_type),
esc_html($product->add_to_cart_text())
), $product);
?>
</td>
</tr>
</table>
<?php
endwhile;
} else {
echo __('No products found');
}
wp_reset_postdata();
?>
Dies ist verwandt: http://stackoverflow.com/questions/27395967/pagination-with-woocomerece-without-plugins/27405231#27405231 – LoicTheAztec