Looking for support? You can access the support system via your account.
Forums › Forums › Search & Filter Pro › Search & filter pro and woocommerce product table
- This topic has 32 replies, 2 voices, and was last updated 10 months, 3 weeks ago by Trevor.
-
Trevor Moderator(Private) April 18, 2019 at 12:11 pm #208723
The first problem I can see looking at the forms and the page itself, are:
You have two forms on the page, this this may well not work, you may need to try this with just one form to see if that works.
The forms are set to ‘As an Archive’, but for the filter_next_query to work, they need to be set to ‘Custom’.
I cannot guarantee that this will work though.
Trevor Moderator(Private) April 18, 2019 at 2:35 pm #208752With just one form, set to custom, if that method does not work, then the table plugin must be doing its own query in a different way. You will need to check their code for calls to wp_query or pre_get_posts.
setgp(Private) April 18, 2019 at 2:51 pm #208764this 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 Moderator(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 Moderator(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
You must be logged in to reply to this topic.