وردپرس

Current product list with product pages (pagination)


Hello,

I would like to extract the product identifiers from the product list. But I would not need the product identifiers of the entire product list, only a subset that currently appears.

This code snippet correctly counts the product IDs, but always only takes the current product page into account and puts the identifiers of those products into the array:

$all_products = $wp_query->posts;
$product_ids = [];
$product_ids = wp_list_pluck($all_products, 'ID');

I would need PHP code that puts the product identifiers into an array in a similar way to the above method, but collects product identifiers from other pages as well if the current product set has multiple product pages (pagination).

The following code is a PHP code snippet belonging to the WP Template that counts the number of products. However, I cannot extract the product identifiers from this. But the logic is appropriate:

if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) { return; } $total = wc_get_loop_prop( 'total' );

I would like to request assistance with this matter.

Thank you!

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا