نمایش دادن محصولات بیشتر از 5 تا در صفحه اول سایت woocommerce

  • نویسنده موضوع dota
  • تاریخ شروع

dota

تازه وارد
سلام

من هر کاری می کنم فقط 5 تا محصول اخر را در صفحه اول سایت نمایش میده

چطور میشه کاری کرد که محصولات بیشتری مثلا 10 تا را در صفحه اول نمایش داد

من دز قسمت تنظیمات این مقدار را افزایش دادم اما تغییری نکرده

لطفا راهنمایی کنید

 

dota

تازه وارد
من تمام درخواست های کمک این انجمن را نگاه کردم

هیچ کدوم پاسخ داده نشده بود !!!!

 

zegersot

کاربر عضو
دوست عزیز تو قوانین سایت نوشته حد اقل 24 ساعت

واسه شما به 35 دقیقه هم نرسیده ! یکم صبر کنید بهتون جواب میدن

بنده هم اطلاعی ندارم اگه داشتم بهتون میگفتم

موفق باشید

 

Mohammad

مدیر انجمن
پرسنل مدیریت
چه قالبی استفاده می کنید؟ ادرس وب سایت لطفا

 

dota

تازه وارد
از این قالب



لطفا راهنمایی کنید

 

dota

تازه وارد
خودم فهمیدم

از تنظیمان قالب option theme قسمتfeatuered silder [h=3]Number of Recent Posts displayed on homepage را هر عددی قرار بدیم در صفحه نمایش میده[/h]

 

Hatefi

کاربر عضو
در تنظیمات --> خواندن ---> تعداد پستها رو افزایش بدید

 

Hatefi

کاربر عضو
احتمالا قالب شما دارای تنظیمات تعداد پست هست

وارد تنظیمات قالبتون بشید و بررسی کنید

 

ervin311

تازه وارد
قالب صفحه اصلی را ویرایش کنید.

index.php

دنبال کد های زیر بگردید و مقدار آن را تغییر دهید

<?php echo do_shortcode('[featured_products per_page="[COLOR=#ff0000]4[/COLOR]" columns="2"]'); ?>

<?php } ?>

</div><!--/#featured-products-->

<div class="product-gallery">

<h2><?php _e('Recent Products', 'woothemes'); ?></h2>

<?php echo do_shortcode('[recent_products per_page="[COLOR=#ff0000]6[/COLOR]" columns="2"]'); ?>

</div><!--/.product-gallery-->

 

skalanter

تازه وارد
من هنوز نتونستم هیچ محصولی رو بیارم صفحه اول -

 

ali2000hos

تازه وارد
×با عرض پوزش به خاطر بالا آوردن تاپیک های قدیمی× ( مجبور بودم ! )

سلام 

اصولا این کار همانطور که دوست عزیزمان اروین گفتند ، توی index.php انجام میشه ولی متنی که باید آن را جس و جو کنید ، در قالب های مختلف فرق می کنه ، مثلا در قالبی که من استفاده میکنم کل فایل ایندکس به صورت زیر می باشد: 

<?php get_header(); ?> <?php global $woo_options; ?><div class="row homepage visible"> <!-- Header widget --> <section class="header-widget"> <?php if ( function_exists('dynamic_sidebar') ) dynamic_sidebar( 'header-widget' ); ?> </section><!--/.header-widget--> <section id="content"> <?php if ( is_woocommerce_activated() ) { ?> <!-- The first featured product --> <div class="featured-1 sixcol"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'yes')) ); $loop = new WP_Query( $args ); if ( function_exists( 'get_product' ) ) { $_product = get_product( $loop->post->ID ); } else { $_product = new WC_Product( $loop->post->ID ); } while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_single'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_single_image_width').'px" height="'.$woocommerce->get_image_size('shop_single_image_height').'px" />'; ?> </a> <div class="meta"> <h2><span><?php _e('Featured Product', 'woothemes'); ?></span> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h2> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php the_excerpt(); ?> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> <?php endwhile; ?> </div><!--/.featured-1--> <!-- 4 recent products --> <div class="recent-1 sixcol last"> <ul class="recent products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'no')) ); $first_or_last = 'first'; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <li class="product sixcol <?php echo $first_or_last; $first_or_last = ('first'==$first_or_last) ? 'last' : 'first'; ?>"> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />'; ?> </a> <div class="meta"> <h3><a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h3> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> </li> <?php endwhile; ?> </ul><!--/ul.recent--> <div class="clear"></div> <!-- Display the homepage widget area --> <?php if ( function_exists('dynamic_sidebar') ) dynamic_sidebar( 'homepage-content' ); ?> </div><!--/.recent-1--> <div class="clear"></div> <!-- 4 more recent products --> <div class="recent-2 sixcol"> <ul class="recent products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'offset' => 4, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'no')) ); $first_or_last = 'first'; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <li class="product sixcol <?php echo $first_or_last; $first_or_last = ('first'==$first_or_last) ? 'last' : 'first'; ?>"> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />'; ?> </a> <div class="meta"> <h3><a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h3> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> </li> <?php endwhile; ?> </ul><!--/ul.recent--> <!-- Display the latest post --> <?php if ( $woo_options[ 'woo_homepage_content' ] == "true" ) { ?> <?php query_posts('posts_per_page=1'); ?> <?php while (have_posts()) : the_post(); ?> <article <?php post_class(); ?>> <h2 class="title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'woothemes' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <aside class="threecol meta"> <ul> <li class="date"><?php the_time('j F Y', '<time>', '</time>'); ?></li> <li class="author"><?php the_author_posts_link(); ?></li> <li class="category"><?php the_category(', '); ?></li> <!--<li class="tags"><?php // the_tags('Tagged: ',', ',''); ?></li>--> <li class="comments"><?php comments_popup_link(__( '0 Comments', 'woothemes' ), __( '1 Comment', 'woothemes' ), __( '% Comments', 'woothemes' )); ?></a></li> <?php the_tags( '<li class="tags">', ', ', '</li>' ); ?></li> </ul> </aside><!--/.meta--> <section class="article-content ninecol last"> <?php the_excerpt(); ?> </section><!--/.article-content--> </article><!--/.post--> <?php endwhile;?> <?php } else { ?> <?php } ?> </div><!--/.recent-2--> <!-- 2nd featured product --> <div class="featured-2 sixcol last"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'offset' => 1, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'yes')) ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_single'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_single_image_width').'px" height="'.$woocommerce->get_image_size('shop_single_image_height').'px" />'; ?> </a> <div class="meta"> <h2><span><?php _e('Featured Product', 'woothemes'); ?></span> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h2> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php the_excerpt(); ?> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> <?php endwhile; ?> </div><!--/.featured-1--> <?php } // endif is_woocommerce_activated() ?> </section> </div><?php get_footer(); ?>اما قسمتی که باید تقییر بدم ۲ قسمت می باشد که به صورت زیر است:

<!-- 4 recent products --> <div class="recent-1 sixcol last"> <ul class="recent products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 6, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'no')) ); $first_or_last = 'first'; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <li class="product sixcol <?php echo $first_or_last; $first_or_last = ('first'==$first_or_last) ? 'last' : 'first'; ?>"> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />'; ?> </a> <div class="meta"> <h3><a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h3> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> </li> <?php endwhile; ?> </ul><!--/ul.recent-->و

<!-- 4 more recent products --> <div class="recent-2 sixcol"> <ul class="recent products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'offset' => 6, 'meta_query' => array( array('key' => '_visibility','value' => array('catalog', 'visible'),'compare' => 'IN'),array('key' => '_featured','value' => 'no')) ); $first_or_last = 'first'; $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $_product; ?> <li class="product sixcol <?php echo $first_or_last; $first_or_last = ('first'==$first_or_last) ? 'last' : 'first'; ?>"> <?php woocommerce_show_product_sale_flash( $post, $_product ); ?> <a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"> <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_catalog_image_width').'px" height="'.$woocommerce->get_image_size('shop_catalog_image_height').'px" />'; ?> </a> <div class="meta"> <h3><a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php // echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>"><?php the_title(); ?></a></h3> <span class="price"><?php echo $product->get_price_html(); ?></span> <?php // woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> </div><!--/.meta--> </li> <?php endwhile; ?> </ul><!--/ul.recent-->در هر دوی این کد ها ، این متن 

product', 'posts_per_page' => ,,وجود دارد اما در دومی به این صورت است.

posts_per_page' => , 'offset' => این دو متن به ثورت پیش فرض در قالب من به صورت زیر بوده:

posts_per_page' => 4
کد:
posts_per_page' => 4, 'offset' => 4
بوده ولی از آنجایی که من تعداد بیشتری در صفحه اول می خواستم ، آن را به صورت زیر تغییر دادم:

posts_per_page' => 8
کد:
posts_per_page' => 8, 'offset' => 4
اما در قسمت پایینی لیست محصولات ، 4 محصول تکرار می شد و همچنین فاصله بین محصولا برجسته با محصولات معمولی زیاد بود
4.png

 
برای همین در نهایت کد ها رو به صورت زیر تغییر دادم اینگونه همان تعداد محصول دارم و محصولی هم تکرار نشده و فاصله هم مناسب است.
کد:
posts_per_page' => 6
کد:
posts_per_page' => 8, 'offset' => 6
5.png


اما همانطور که گفتم این ها در هر قالبی بسته به اعصاب طراح قالب ، متفاوته!! :)

 
آخرین ویرایش توسط مدیر:
بالا