我使用的是WP电子商务插件版本3.8.12.1
我使用了一个自定义的post类型“event”和多值字段“event\\u photos”,字段类型是wpsc product。
要显示单个“事件”,请使用单个事件。php:
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the single view for the event.
*/
include TEMPLATEPATH.\'/event-templates/single.php\';
<?php endwhile; // end of the loop. ?>
要显示自定义类型“event”的产品列表,请使用“/事件模板/single.php”:
<div class="entry-show-products">
<?php $event_photos_obj = get_field(\'event_photos\'); //Show product in a list
if( $event_photos_obj ) :
echo \'<ul>\';
foreach ($event_photos_obj as $products) :
setup_postdata($products);?>
<li>
<?php
$target_product = get_field(\'event_picture_photo\', $products->ID);
?>
<div class="imagecol">
<?php
if ( wpsc_the_product_thumbnail(0,0,$products->ID) ) : ?>
<a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(
); ?>" href="<?php echo esc_url( wpsc_the_product_image(0,0,$products->ID) ); ?>">
<img class="product_image" id="product_image_<?php echo $products->ID ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(0,0,$products->ID); ?>"/>
</a>
<?php endif; ?>
</div><!--close imagecol-->
</li>
<?php endforeach;
echo \'</ul>\';
else :
echo "Δεν υπάρχει φωτογραφία";
endif; ?>
</div><!-- .entry-show-photo -->
我的问题是如何告诉wp在特定产品中建立索引,然后使用模板代码“wpsc-single\\u product.php”:
<div id="single_product_page_container">
<?php
// Breadcrumbs
wpsc_output_breadcrumbs();
// Plugin hook for adding things to the top of the products page, like the live search
do_action( \'wpsc_top_of_products_page\' );
?>
<div class="single_product_display group">
<?php
/**
* Start the product loop here.
* This is single products view, so there should be only one
*/
?>
<div class="imagecol">
<?php if ( wpsc_the_product_thumbnail() ) : ?>
<a rel="<?php echo wpsc_the_product_title(); ?>" class="<?php echo wpsc_the_product_image_link_classes(); ?>" href="<?php echo esc_url( wpsc_the_product_image() ); ?>">
<img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>
</a>
<?php
if ( function_exists( \'gold_shpcrt_display_gallery\' ) )
echo gold_shpcrt_display_gallery( wpsc_the_product_id() );
?>
<?php else: ?>
<a href="<?php echo esc_url( wpsc_the_product_permalink() ); ?>">
<img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option(\'product_image_width\'); ?>" height="<?php echo get_option(\'product_image_height\'); ?>" />
</a>
<?php endif; ?>
</div><!--close imagecol-->
</div><!--close single_product_display-->
<?php echo wpsc_product_comments(); ?>
<?php do_action( \'wpsc_theme_footer\' ); ?>
</div><!--close single_product_page_container-->
使用WP\\u查询是更好的方法吗?