Hi!
ZIP-link is 404, unfortunately.
Use-case:
My related post – is a products (goods), not news or notes. I need in Related Products section of Product page see only in-stock goods. But YARPP can show all related products: in stock and out of stock. (YARPP is guided by the principles of related posts, and I also need to see only those related posts (products) that are currently in stock.)
I need see maximum 6 goods in Related Product section in Product page, but more or less at other place of web-shop’s, or other count of items at other time… without re-cache YARPP (in Settings i have 18 in Max related posts and can change this parameter in my code at any moment).
/*
* Filter wp_query of YARPP Plugin
*/
add_filter('yarpp_display_related_wp_query', 'yarpp_custom_wp_query');
function yarpp_custom_wp_query($args) {
// Show in-stock only
$meta_query = [
[
'key' => 'sklad_1',
'value' => 0,
'compare' => '>',
'type' => 'numeric',
]
];
$args = [
'post_status' => 'publish',
'order' => $args['order'],
'orderby' => $args['orderby'],
'p' => $args['p'],
'post_type' => $args['post_type'],
// Set more in Setting in Admin panel
// so that at least 6 of them (possibly fewer) can be shown
'showposts' => 6,
'meta_query' => $meta_query,
];
return $args;
}
Sorry, but i can’t test code on production ??