رفتن به مطلب

صفحه 2 فروشگاه کار نمیکند و مشکل NOT FOUND می دهد


پست های پیشنهاد شده

با احترام به دوستان عزیز

من یه صفحه ایجاد کردم با نام 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(); ?>

 

 

کسی از دوستان میتونه کمک کنه؟

لینک به ارسال

میشه محبت کنین بیشتر توضیح بدین ! چون خیلی وقته که درگیرش هستم. این کد را در 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";

}

 

لینک به ارسال

@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(); ?>

اگر مشکل دیگه ای نداشته باشه درست میشه.

لینک به ارسال
در 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(); ?>

اگر مشکل دیگه ای نداشته باشه درست میشه.

ممنونم از پیگیریت. با کدهایی که ارسال کردین کلی ور رفتم ولی بازم نشد که بشه !

خیلی ممنونم از شما

لینک به ارسال
در 7 ساعت قبل، Roozbeh_gol گفته است :

ممنونم از پیگیریت. با کدهایی که ارسال کردین کلی ور رفتم ولی بازم نشد که بشه !

بله از کوئریتون هم زیاد سر در نیاورم ممکنه ایراد داشته باشه.

در 7 ساعت قبل، Roozbeh_gol گفته است :

خیلی ممنونم از شما

خواهش میکنم

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...