Custom post type list with pagination in while loop

<?php

$loop = new WP_Query(array(‘post_type’ => ‘custom_post’,  ‘posts_per_page’ => 5,  ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1 ));

?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<?php the_title(); ?> <?php the_content(); ?>

<?php endwhile; ?>

<?php  $uniqnum = 999999999;

echo paginate_links( array( ‘base’ => str_replace( $uniqnum, ‘%#%’, get_pagenum_link( $uniqnum ) ),

‘format’ => ‘?paged=%#%’,

‘current’ => max( 1, get_query_var(‘paged’) ),

‘total’ => $loop->max_num_pages ) );

?>

Restrict specific products in Woo-Commerce shop

Put below code in functions.php

add_action( ‘woocommerce_product_query’, ‘aviweb_product_query’ );add_action( ‘woocommerce_product_query’, ‘aviweb_product_query’ );
function aviweb_product_query( $q_array ){

$product_ids_on_sale = array(); $product_ids_on_sale[] = 7076;

$q_array->set( ‘post__not_in’, $product_ids_on_sale );

}

post__in -> products within array

post__not_in -> products not in array

Change order of billing fields on woo-commerce checkout page

We can change fields order based on priority please find below code to change FIELD ORDER

add_filter(“woocommerce_checkout_fields”, “order_fields”);

function order_fields($fields) {

$fields[‘billing’][‘billing_first_name’][‘priority’] = 1;
$fields[‘billing’][‘billing_last_name’][‘priority’] = 2;
$fields[‘billing’][‘billing_company’][‘priority’] = 3;
$fields[‘billing’][‘billing_email’][‘priority’] = 4;
$fields[‘billing’][‘billing_phone’][‘priority’] = 5;
$fields[‘billing’][‘billing_country’][‘priority’] = 6;
$fields[‘billing’][‘billing_address_1’][‘priority’] = 7;
$fields[‘billing’][‘billing_address_2’][‘priority’] = 8;
$fields[‘billing’][‘billing_city’][‘priority’] = 9;
$fields[‘billing’][‘billing_state’][‘priority’] = 10;
$fields[‘billing’][‘billing_postcode’][‘priority’] = 11;

return $fields;
}