我正在检查是否有人知道如何通过短代码或任何其他方法显示产品说明而没有图像和描述等。
我有很多关于woo-commerce短代码的文章但没有这个具体。我使用它作为滑块的一部分,我不希望产品的图像显示在那里只有产品名称和描述,也许价格?
所以我正在编辑archive-product.php
我在这个页面中有一个滑块,我想要显示一个'特色项目'但没有图像只是描述:
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
*
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
get_header( 'shop' ); ?>
<!-- Featured product title and desciption -->
<?php
ini_set('max_execution_time', 0); //I saw maximum execution time error on your image - this is for that
$args = array(
'post_status' => 'publish',
'post_type' => 'product',
'meta_value' => 'yes',
'posts_per_page' => 1,
'product_cat' => 'grammar'
);
$product_query = new WP_Query( $args );
?>
<div class="shopBanner">
<div class="container">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item" id="id1">
<div class="section group">
<?php if ($product_query->have_posts()) : ?>
<?php while ($product_query->have_posts()) : ?>
<div class="col span_2_of_3">
<h1><?php echo $product_query->post->post_title; ?></h1>
<h2 style="margin-top:-20px;">
<?php echo $product_query->post->post_excerpt; ?>
</h2>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div class="col span_1_of_3">
<span class="icon lush-comments" id="heroIcon"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Link button to featured product -->
<div class="section1" id="section1">
<div class="container">
<button class="mainbtn" style="float: left; margin-top: -82px;">View product</button>
<div class="section group">
<div class="col span_2_of_3">
Take a look of our range of publications. Selected publications can be purchased via a download also.
</div>
<div class="col span_1_of_3">
<div style="float:right;">
<a href="https://twitter.com/" target="_blank"><button class="social" style="background-image:url(img/twitterIcon.png);"></button></a>
<a href="https://www.facebook.com/" target="_blank"><button class="social" style="background-image:url(img/facebookIcon.png);"></button></a>
</div>
</div>
</div>
</div>
</div>
<div class="section1" style="padding: 0px 0 50px 0;">
<div class="container">
<div style="background-color: #fff; width:100%; color: #777777;">
<div style="padding: 20px; margin-bottom:-15px;">
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<!--<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<h3 style="color: #1dae5e; text-shadow:none; font-weight:600; font-size: 1.3em; margin-bottom:20px;"><?php woocommerce_page_title(); ?></h3>
<?php endif; ?>-->
<span style="float: right; margin-top:-40px;">
<a class="shopNav" href="?post_type=product">Back to Shop</a>
<a class="shopNav" href="?page_id=13">My Account</a>
<a class="shopNav" href="?page_id=11">Basket</a>
<a class="shopNav" href="?page_id=12">Checkout</a>
</span>
</div></div></div></div>
<div class="section1" style="padding: 40px 0 50px 0;">
<div class="container">
<div style="background-color: #fff; width:100%; color: #777777;">
<div style="padding: 20px;">
<?php do_action( 'woocommerce_archive_description' ); ?>
<?php if ( have_posts() ) : ?>
<?php
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination - 10
*/
do_action( 'woocommerce_after_shop_loop' );
?>
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
<?php wc_get_template( 'loop/no-products-found.php' ); ?>
<?php endif; ?>
<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
</div>
</div>
</div>
</div>
<?php get_footer( 'shop' ); ?>
答案 0 :(得分:1)
以下代码将获得10个 grammer 类别的产品,并发布状态。可能会有所帮助。
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
*
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
get_header( 'shop' ); ?>
<!-- Featured product title and desciption -->
<?php
ini_set('max_execution_time', 0); //I saw maximum execution time error on your image - this is for that
$args = array(
'post_status' => 'publish',
'post_type' => 'product',
'meta_value' => 'yes',
'posts_per_page' => 10,
'product_cat' => 'grammar'
);
$product_query = new WP_Query( $args );
?>
<div class="shopBanner">
<div class="container">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item" id="id1">
<div class="section group">
<?php while ( $product_query->have_posts() ) : $product_query->the_post(); global $product; ?>
<div class="col span_2_of_3">
<h1><?php the_title(); ?></h1>
<h2 style="margin-top:-20px;">
<?php echo apply_filters( 'woocommerce_short_description', $product->post->post_excerpt ); ?>
</h2>
</div>
<?php endwhile; ?>
<div class="col span_1_of_3">
<span class="icon lush-comments" id="heroIcon"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Link button to featured product -->
<div class="section1" id="section1">
<div class="container">
<button class="mainbtn" style="float: left; margin-top: -82px;">View product</button>
<div class="section group">
<div class="col span_2_of_3">
Take a look of our range of publications. Selected publications can be purchased via a download also.
</div>
<div class="col span_1_of_3">
<div style="float:right;">
<a href="https://twitter.com/" target="_blank"><button class="social" style="background-image:url(img/twitterIcon.png);"></button></a>
<a href="https://www.facebook.com/" target="_blank"><button class="social" style="background-image:url(img/facebookIcon.png);"></button></a>
</div>
</div>
</div>
</div>
</div>
<div class="section1" style="padding: 0px 0 50px 0;">
<div class="container">
<div style="background-color: #fff; width:100%; color: #777777;">
<div style="padding: 20px; margin-bottom:-15px;">
<?php
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php //if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<!-- <h3 style="color: #1dae5e; text-shadow:none; font-weight:600; font-size: 1.3em; margin-bottom:20px;"><?php woocommerce_page_title(); ?></h3>-->
<?php //endif; ?>
<span style="float: right; margin-top:-40px;">
<a class="shopNav" href="?post_type=product">Back to Shop</a>
<a class="shopNav" href="?page_id=13">My Account</a>
<a class="shopNav" href="?page_id=11">Basket</a>
<a class="shopNav" href="?page_id=12">Checkout</a>
</span>
</div>
</div>
</div>
</div>
<div class="section1" style="padding: 40px 0 50px 0;">
<div class="container">
<div style="background-color: #fff; width:100%; color: #777777;">
<div style="padding: 20px;">
<?php do_action( 'woocommerce_archive_description' ); ?>
<?php if ( have_posts() ) : ?>
<?php
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination - 10
*/
do_action( 'woocommerce_after_shop_loop' );
?>
<?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>
<?php wc_get_template( 'loop/no-products-found.php' ); ?>
<?php endif; ?>
<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
</div>
</div>
</div>
</div>
<?php get_footer( 'shop' ); ?>