Roozbeh_gol 0 ارسال شده در تیر 99 گزارش بازنشر ارسال شده در تیر 99 با احترام به دوستان عزیز من یه صفحه ایجاد کردم با نام archive-product ایجاد کردم و تمپلیت خودم درست کردم. همه چی اوکیه بجز صفحه بندیش.زمانیکه بر روی صفحه 2 یا بیشتر کلیک میکنم پیام 404 میده. کد archive-product <?php get_header(); ?> <ul class="cards"> <?php global $product; $woocommerce_category_id = get_queried_object_id(); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => 'product', 'post_status'=>'publish', 'product_cat'=>woocommerceCategorySlug( $woocommerce_category_id ) , 'paged'=>$paged, ); $wp_query = new WP_Query($args); if($wp_query->have_posts()): while ($wp_query->have_posts()): $wp_query->the_post(); global $product; $do_not_duplicate = $post->ID; ?> <li class="cards__item"> <div class="card"> <?php the_post_thumbnail(); ?> <a href="<?php the_permalink() ?>"><div class="card__title"><?php the_title(); ?> </div></a> <!-- start price --> </div> <!-- end price --> <button id="myWish"class="card__btn"><?php do_action( 'woocommerce_after_shop_loop_item' ); ?></button> </div> </li> <?php endwhile; ?> </ul> <div class="in-paginate"><?php wpbeginner_numeric_posts_nav(); ?></div></br> <?php echo product_count(); ?> <?php endif;?> <?php get_footer(); ?> کسی از دوستان میتونه کمک کنه؟ نقل قول لینک به ارسال
mehran-b 2385 ارسال شده در تیر 99 گزارش بازنشر ارسال شده در تیر 99 @Roozbeh_gol به علت اینکه از کاستوم کوئری استفاده کردید صفحه بندی متفاوت میشه. اون تابعی که پیج نویگیشن رو نمایش میده کدهاش رو ارسال کنید. نقل قول لینک به ارسال
Roozbeh_gol 0 ارسال شده در تیر 99 مالک گزارش بازنشر ارسال شده در تیر 99 میشه محبت کنین بیشتر توضیح بدین ! چون خیلی وقته که درگیرش هستم. این کد را در function قرار دادم. /*---------------------------------------------------------------------------------------------------------------- Numeric Pagination ----------------------------------------------------------------------------------------------------------------*/ function wpbeginner_numeric_posts_nav() { if( is_singular() ) return; global $wp_query; /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="navigation"><ul>' . "\n"; /** Previous Post Link */ if ( get_previous_posts_link() ) printf( '<li>%s</li>' . "\n", get_previous_posts_link() ); /** Link to first page, plus ellipses if necessary */ if ( ! in_array( 1, $links ) ) { $class = 1 == $paged ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) echo '<li>…</li>'; } /** Link to current page, plus 2 pages in either direction if necessary */ sort( $links ); foreach ( (array) $links as $link ) { $class = $paged == $link ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); } /** Link to last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) echo '<li>…</li>' . "\n"; $class = $paged == $max ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); } /** Next Post Link */ if ( get_next_posts_link() ) printf( '<li>%s</li>' . "\n", get_next_posts_link() ); echo '</ul></div>' . "\n"; } نقل قول لینک به ارسال
mehran-b 2385 ارسال شده در تیر 99 گزارش بازنشر ارسال شده در تیر 99 @Roozbeh_gol کد صفحه بندی باید به شکل زیر بشه. /*---------------------------------------------------------------------------------------------------------------- Numeric Pagination ----------------------------------------------------------------------------------------------------------------*/ function wpbeginner_numeric_posts_nav($query = null) { if( is_singular() ) return; if(isset($query)) { $wp_query = $query; } else { global $wp_query; } /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="navigation"><ul>' . "\n"; /** Previous Post Link */ if ( get_previous_posts_link() ) printf( '<li>%s</li>' . "\n", get_previous_posts_link() ); /** Link to first page, plus ellipses if necessary */ if ( ! in_array( 1, $links ) ) { $class = 1 == $paged ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) echo '<li>…</li>'; } /** Link to current page, plus 2 pages in either direction if necessary */ sort( $links ); foreach ( (array) $links as $link ) { $class = $paged == $link ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); } /** Link to last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) echo '<li>…</li>' . "\n"; $class = $paged == $max ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); } /** Next Post Link */ if ( get_next_posts_link() ) printf( '<li>%s</li>' . "\n", get_next_posts_link() ); echo '</ul></div>' . "\n"; } و همچنین کد خود صفحه میشه: <?php get_header(); ?> <ul class="cards"> <?php global $product; $woocommerce_category_id = get_queried_object_id(); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => 'product', 'post_status'=>'publish', 'product_cat'=>woocommerceCategorySlug( $woocommerce_category_id ) , 'paged'=>$paged, ); $wp_query = new WP_Query($args); if($wp_query->have_posts()): while ($wp_query->have_posts()): $wp_query->the_post(); global $product; $do_not_duplicate = $post->ID; ?> <li class="cards__item"> <div class="card"> <?php the_post_thumbnail(); ?> <a href="<?php the_permalink() ?>"><div class="card__title"><?php the_title(); ?> </div></a> <!-- start price --> </div> <!-- end price --> <button id="myWish"class="card__btn"><?php do_action( 'woocommerce_after_shop_loop_item' ); ?></button> </div> </li> <?php endwhile; ?> </ul> <div class="in-paginate"><?php wpbeginner_numeric_posts_nav($wp_query); ?></div></br> <?php echo product_count(); ?> <?php endif;?> <?php get_footer(); ?> اگر مشکل دیگه ای نداشته باشه درست میشه. 1 نقل قول لینک به ارسال
Roozbeh_gol 0 ارسال شده در تیر 99 مالک گزارش بازنشر ارسال شده در تیر 99 در 18 ساعت قبل، mehran-b گفته است : @Roozbeh_gol کد صفحه بندی باید به شکل زیر بشه. /*---------------------------------------------------------------------------------------------------------------- Numeric Pagination ----------------------------------------------------------------------------------------------------------------*/ function wpbeginner_numeric_posts_nav($query = null) { if( is_singular() ) return; if(isset($query)) { $wp_query = $query; } else { global $wp_query; } /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="navigation"><ul>' . "\n"; /** Previous Post Link */ if ( get_previous_posts_link() ) printf( '<li>%s</li>' . "\n", get_previous_posts_link() ); /** Link to first page, plus ellipses if necessary */ if ( ! in_array( 1, $links ) ) { $class = 1 == $paged ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) echo '<li>…</li>'; } /** Link to current page, plus 2 pages in either direction if necessary */ sort( $links ); foreach ( (array) $links as $link ) { $class = $paged == $link ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); } /** Link to last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) echo '<li>…</li>' . "\n"; $class = $paged == $max ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); } /** Next Post Link */ if ( get_next_posts_link() ) printf( '<li>%s</li>' . "\n", get_next_posts_link() ); echo '</ul></div>' . "\n"; } و همچنین کد خود صفحه میشه: <?php get_header(); ?> <ul class="cards"> <?php global $product; $woocommerce_category_id = get_queried_object_id(); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => 'product', 'post_status'=>'publish', 'product_cat'=>woocommerceCategorySlug( $woocommerce_category_id ) , 'paged'=>$paged, ); $wp_query = new WP_Query($args); if($wp_query->have_posts()): while ($wp_query->have_posts()): $wp_query->the_post(); global $product; $do_not_duplicate = $post->ID; ?> <li class="cards__item"> <div class="card"> <?php the_post_thumbnail(); ?> <a href="<?php the_permalink() ?>"><div class="card__title"><?php the_title(); ?> </div></a> <!-- start price --> </div> <!-- end price --> <button id="myWish"class="card__btn"><?php do_action( 'woocommerce_after_shop_loop_item' ); ?></button> </div> </li> <?php endwhile; ?> </ul> <div class="in-paginate"><?php wpbeginner_numeric_posts_nav($wp_query); ?></div></br> <?php echo product_count(); ?> <?php endif;?> <?php get_footer(); ?> اگر مشکل دیگه ای نداشته باشه درست میشه. ممنونم از پیگیریت. با کدهایی که ارسال کردین کلی ور رفتم ولی بازم نشد که بشه ! خیلی ممنونم از شما نقل قول لینک به ارسال
mehran-b 2385 ارسال شده در تیر 99 گزارش بازنشر ارسال شده در تیر 99 در 7 ساعت قبل، Roozbeh_gol گفته است : ممنونم از پیگیریت. با کدهایی که ارسال کردین کلی ور رفتم ولی بازم نشد که بشه ! بله از کوئریتون هم زیاد سر در نیاورم ممکنه ایراد داشته باشه. در 7 ساعت قبل، Roozbeh_gol گفته است : خیلی ممنونم از شما خواهش میکنم 1 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .