Forums › Forums › Search & Filter Pro › Search & filter pro and woocommerce product table
- This topic has 32 replies, 2 voices, and was last updated 2 years, 5 months ago by
Trevor.
-
Anonymous(Private) April 18, 2019 at 2:51 pm #208764
this is the code that woocommerce product table use for the query i presume:
$args = shortcode_parse_atts( str_replace( array( ‘[product_table’, ‘]’ ), ”, $shortcode ) );
$args = ! empty( $args ) && is_array( $args ) ? $args : array();if ( is_product_category() ) {
// Product category archive
$args[‘category’] = get_queried_object_id();
} elseif ( is_product_tag() ) {
// Product tag archive
$args[‘tag’] = get_queried_object_id();
} elseif ( is_product_taxonomy() ) {
// Other product taxonomy archive
$term = get_queried_object();
$args[‘term’] = “{$term->taxonomy}:{$term->term_id}”;
} elseif ( is_post_type_archive( ‘product’ ) && get_query_var( ‘s’ ) ) {
// Product search results page
add_filter( ‘wc_product_table_run_in_search’, ‘__return_true’ );if ( have_posts() ) {
global $wp_query;
$args[‘include’] = wp_list_pluck( $wp_query->posts, ‘ID’ );
} else {
// Force ‘nothing found’ message if no posts in query
$args[‘include’] = -1;
}
}Trevor(Private) April 18, 2019 at 2:59 pm #208770Could you try changing this bit (you need to use the ID of the form you retained on the page instead of ‘123456’):
if ( have_posts() ) { global $wp_query; $args['include'] = wp_list_pluck( $wp_query->posts, 'ID' ); } else {to
if ( have_posts() ) { global $wp_query; $args['include'] = wp_list_pluck( $wp_query->posts, 'ID' ); $args['search_filter_id'] = 123456; } else {But I am not confident this will work, but here’s hoping. You will need to remove the shortcode that has the filter_next_query in it.
Trevor(Private) April 18, 2019 at 3:51 pm #208790Those two shortcodes will output the form, but will not output any posts unless there is something on the page to do that also, and then they might need to be tied together. On that page there are no posts, so I assume that there is nothing on the page outputting them?
The process is generally this:
Output the form
Send the selected form filters to the plugin, theme template or pagebuilder posts element.
Output the posts.For the custom method, it is necessary to manually join those together (for example using the filter_next_query shortcode, or adding the args line).
Most other form Display Results methods do the joining for you.
-
AuthorPosts