Possible to filter custom loop on archive.php?
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from malmomen on August 10, 2020, 20:52How can I use WOOF filter on a custom loop on my archive.php?
Here is my loop:
// Setup your custom query
$loop = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'product_cat', // The taxonomy name
'field' => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
'terms' => $term->term_id, // can be an integer, a string or an array
) ),
) );if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
the_post_thumbnail( 'thumbnail');
echo '<div style="margin:25px;">';
$step1 = get_field ( "example1" );
$step2 = get_field('example3', 'user_'.$step1 );
$data = array(
'foo' => 'bar',
'baz' => 'boom',
'cow' => 'milk',
'php' => 'hypertext processor'
);
$base_url = 'https://my-site.com/?page_id=1123/';
$query_params = http_build_query($data);
$link = $base_url . '?' . $query_params;
echo '<strong>';
echo '<a href = "' . $link . '">' .$step2. '</a>';
echo '</strong>';
echo '<br>';
$example2 = get_field ( "example2" );
echo '<a href="' .$destinationlink. '" target="_blank">';
the_title();
echo "</a>";
endwhile;
wp_reset_postdata(); // Remember to reset
endif; endif;
?>
How can I use WOOF filter on a custom loop on my archive.php?
Here is my loop:
// Setup your custom query
$loop = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'product_cat', // The taxonomy name
'field' => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
'terms' => $term->term_id, // can be an integer, a string or an array
) ),
) );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post();
the_post_thumbnail( 'thumbnail');
echo '<div style="margin:25px;">';
$step1 = get_field ("example1" );
$step2 = get_field('example3', 'user_'.$step1 );
$data = array(
'foo' => 'bar',
'baz' => 'boom',
'cow' => 'milk',
'php' => 'hypertext processor'
);
$base_url = 'https://my-site.com/?page_id=1123/';
$query_params = http_build_query($data);
$link = $base_url . '?' . $query_params;
echo '<strong>';
echo '<a href ="' . $link . '">' .$step2. '</a>';
echo '</strong>';
echo '<br>';
$example2 = get_field ("example2" );
echo '<a href="' .$destinationlink. '" target="_blank">';
the_title();
echo"</a>";
endwhile;
wp_reset_postdata(); // Remember to reset
endif; endif;
?>
Quote from Pablo Borysenco on August 11, 2020, 11:56Hello
Use this code to adapt query arguments
global $WOOF;
if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
$_REQUEST['woof_products_doing'] = 1;
$query_args['tax_query'] = array_merge($query_args['tax_query'], $WOOF->get_tax_query(''));
$query_args['meta_query'] = array_merge($query_args['meta_query'], $WOOF->get_meta_query());
$query_args = apply_filters('woof_products_query', $query_args);if (isset($_GET['paged'])) {
$query_args['paged'] = intval($_GET['paged']);
}
// @codingStandardsIgnoreStart
if (isset($_GET['orderby'])) {
$ordering_args = WC()->query->get_catalog_ordering_args();
} else {
$ordering_args = WC()->query->get_catalog_ordering_args($query_args['orderby'], $query_args['order']);
}
$query_args['orderby'] = $ordering_args['orderby'];
$query_args['order'] = $ordering_args['order'];
if ($ordering_args['meta_key']) {
$query_args['meta_key'] = $ordering_args['meta_key'];
}
}
Hello
Use this code to adapt query arguments
global $WOOF;
if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
$_REQUEST['woof_products_doing'] = 1;
$query_args['tax_query'] = array_merge($query_args['tax_query'], $WOOF->get_tax_query(''));
$query_args['meta_query'] = array_merge($query_args['meta_query'], $WOOF->get_meta_query());
$query_args = apply_filters('woof_products_query', $query_args);
if (isset($_GET['paged'])) {
$query_args['paged'] = intval($_GET['paged']);
}
// @codingStandardsIgnoreStart
if (isset($_GET['orderby'])) {
$ordering_args = WC()->query->get_catalog_ordering_args();
} else {
$ordering_args = WC()->query->get_catalog_ordering_args($query_args['orderby'], $query_args['order']);
}
$query_args['orderby'] = $ordering_args['orderby'];
$query_args['order'] = $ordering_args['order'];
if ($ordering_args['meta_key']) {
$query_args['meta_key'] = $ordering_args['meta_key'];
}
}
Quote from malmomen on August 11, 2020, 18:01Thank you. I'm new-ish to Wordpress, can you explain to me where to put this? I added your code above my loop on archive.php, and tried to use sidebar Woof Filter on archive.php, but it did not filter the products when I tested.
Thank you. I'm new-ish to Wordpress, can you explain to me where to put this? I added your code above my loop on archive.php, and tried to use sidebar Woof Filter on archive.php, but it did not filter the products when I tested.
Quote from Pablo Borysenco on August 12, 2020, 11:50Hello
If you have no experience in programming, you should hire a developer
https://c2n.me/48J6j1C.png
And add above this code -
$query_args=array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'product_cat', // The taxonomy name
'field' => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
'terms' => $term->term_id, // can be an integer, a string or an array
) ),
);
Hello
If you have no experience in programming, you should hire a developer
And add above this code -
$query_args=array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array( array(
'taxonomy' => 'product_cat', // The taxonomy name
'field' => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
'terms' => $term->term_id, // can be an integer, a string or an array
) ),
);