A
A
alex88a2017-08-26 13:23:48
PHP
alex88a, 2017-08-26 13:23:48

How to sort products by additional fields in woocommerce?

Added additional fields with this code

$rrp2 = get_post_meta( $product->id, 'custom_price-2', true );
    $rrp3 = get_post_meta( $product->id, 'custom_price-3', true );
    $rrp4 = get_post_meta( $product->id, 'custom_price-4', true );

The code is not all of course.
Displayed by shortcode
[featured_products per_page="50" columns="4" orderby="date" order="desc"]

How to make it so that it would display the price from the additional field custom_price-4 ? This is a field with numeric values. I have already tried a bunch of options from the Internet and nothing (Thanks in advance for your time!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-08-26
@AXP-dev

featured_productsCan only accept: per_page, columns, orderby, order
Here are the default values:

'per_page' => '12',
'columns'  => '4',
'orderby'  => 'date',
'order'    => 'desc'

You will need to make a new shortcode. Just copy the current one and add the parameters there. Here is the woocommerce.wp-a2z.org/oik_api/wc_shortcodesfeatur...
widget code. Here you can find ways to filter the request https://wp-kama.ru/function/wp_query

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question