Skip to content

Instantly share code, notes, and snippets.

@andykeith
Created October 8, 2019 11:53
Show Gist options
  • Save andykeith/ef801cdb07a5040665b4a72d5fb6aad7 to your computer and use it in GitHub Desktop.
Save andykeith/ef801cdb07a5040665b4a72d5fb6aad7 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'wc_product_table_query_args', function( $args, WC_Product_Table_Query $wpt_query ) {
// The 'args' property - type WC_Product_Table_Args - contains all the shortcode options used to create the table.
// Example checking the category option...
if ( 'something' === $wpt_query->args->category ) {
// Do something with the query args for this table
}
// Another example...
if ( $wpt_query->args->lazy_load ) {
// Do something with the query args for this table
}
// Another example...
if ( 'date' === $wpt_query->args->sort_by ) {
// Do something with the query args for this table
}
return $args;
}, 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment