WordPress custom search – pagination

Working code:

$display_count = 2;
global $wp_query, $paged;
$pages = $wp_query->max_num_pages;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$offset =  $page - 1;
$showposts = 10;
    $args = array(
        'showposts' => 20,
        'post_type' => 'any',
        'post__in'      => $WPIDs,
        'orderby' => 'meta_value',
        'meta_key' => 'cf_dimensjon',
        'order' => 'ASC',
        'number'     =>  $display_count,
        'paged'       =>  $paged

);

$wp_query  = new WP_Query( $args );

 //The Loop
while ( $wp_query ->have_posts() ) : $wp_query  ->the_post();
global $product;
//echo $wp_query->request;

if((int)$product->stock > 0 ){

 $url2 = get_permalink( $product_id );
 $url = $product->add_to_cart_url($p);
 $price = get_post_meta( get_the_ID(), '_regular_price', true);
$stock = get_post_meta( get_the_ID(), '_stock', true);
$pic = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );
$bredde = array_shift(woocommerce_get_product_terms($product->id, 'cf_felgbredde',         'names'));
$bredde = get_post_meta(  get_the_ID(), 'cf_felgbredde', true );
$hoyde = array_shift(woocommerce_get_product_terms($product->id, 'cf_hoyde', 'names'));
$hoyde = get_post_meta(  get_the_ID(), 'cf_hoyde', true );
$dim = array_shift(woocommerce_get_product_terms($product->id, 'cf_dimensjon', 'names'));
$dim = get_post_meta(  get_the_ID(), 'cf_dimensjon', true );
$innpress = array_shift(woocommerce_get_product_terms($product->id, 'pa_felg-bredde', 'names'));
$innpress = get_post_meta(  get_the_ID(), 'cf_innpress', true );
$produktgruppeny = array_shift(woocommerce_get_product_terms($product->id,     'pa_produktgruppeny', 'names'));


echo  '<div>
     <div style="float:left;"><a href="'.$url2.'"><img width="64" height="64"     src="'.$pic.'" class="attachment-shop_catalog wp-post-image" alt="Standard bilde -     sommerdekk" style="padding-right: 10px;"></a></div>
      <div style="float:left;width: 390px;padding-top: 12px"><h3><a     href="'.$url2.'">'. the_title( $before, $after, $echo ) .'</a><span class="amount"     style="font-weight: normal;color: #f7f2f7;" >'  . ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;     &nbsp; &nbsp;'   . ' '. '</span></h3>
      <span style="color:#FFFFFF;"> Dim: '.$dim.' Innpress: '.$innpress .  ' Lager :     ' . $stock . ' </span></div>
      <div style="float:left;margin-left: 45px;padding-top: 12px;"><form class="cart"     method="post" enctype="multipart/form-data">
        <div class="quantity buttons_added" style="float: left; margin-right: 11px;">    <input type="button" value="-" class="minus">
        <input type="number" step="1" min="1" name="quantity" value="1"     title="Antall" class="input-text qty text" size="4">
        <input type="button" value="+" class="plus"></div>
        <input type="hidden" name="add-to-cart" value="'.get_the_ID().'">
        <button type="submit" class="single_add_to_cart_button button     alt">Kjøp</button>&nbsp; ' . $price . ' kr ' . '
        </form></div>
    <div style="clear:both;border-bottom: 1px solid #827f82;margin-bottom:     0px;padding-top: 0px;"></div>
  </div>'; }
//

endwhile;