$action_query = new WP_Query( [
'post_type' => 'action',
'post_status' => 'publish',
] );
/**
* Изменение количества продуктов на странице
*
* @compatible WooCommerce 3.2.0 +
* @see https://github.com/woocommerce/woocommerce/blob/7701d4b57cb20dc89e25bb7bf2ff872d85f4c535/includes/class-wc-query.php#L412
*/
function loop_product_per_page( $per_page ) {
if ( ! empty( $_GET[ 'products-per-page' ] ) ) {
$per_page = (int) ( $_GET[ 'products-per-page' ] );
} else {
$per_page = 12;
}
return $per_page;
}
add_filter( 'loop_shop_per_page', 'loop_product_per_page', 9999 );
/**
* Define default terms for custom taxonomies in WordPress 3.0.1
*
* @author Michael Fields http://wordpress.mfields.org/
* @props John P. Bloch http://www.johnpbloch.com/
* @props Evan Mulins https://circlecube.com/circlecube/
*
* @since 2010-09-13
* @alter 2013-01-31
*
* @license GPLv2
*/
function mfields_set_default_object_terms( $post_id, $post ) {
if ( 'publish' === $post->post_status && $post->post_type === 'your_custom_post_type' ) {
$defaults = array(
'your_taxonomy_id' => array( 'your_term_slug' )
);
$taxonomies = get_object_taxonomies( $post->post_type );
foreach ( (array) $taxonomies as $taxonomy ) {
$terms = wp_get_post_terms( $post_id, $taxonomy );
if ( empty( $terms ) && array_key_exists( $taxonomy, $defaults ) ) {
wp_set_object_terms( $post_id, $defaults[$taxonomy], $taxonomy );
}
}
}
}
add_action( 'save_post', 'mfields_set_default_object_terms', 100, 2 );