White Rock WP主题和WooCommerce兼容性问题

时间:2014-02-27 23:38:53

标签: php wordpress wordpress-plugin wordpress-theming woocommerce

已更新

这是一个特定于情侣项目的问题,所以如果需要请详细询问,我会尽力提供。

问题: 我正在使用一个名为“White Rock”的WordPress主题(http://themeforest.net/item/white-rock-restaurant-winery-theme/3317744)。此主题与WooCommerce没有内置的兼容性。但是,我已经设法让99%的东西使用一些代码更改和其他插件。当您浏览到单个产品页面(https://www.parisisrestaurant.com/wptest/product/1048/)时,没有显示标题图像,如下所示:https://www.parisisrestaurant.com/wptest/shop/store/

主题使用“特色图像”页面将图像附加到页面的标题中。但是,由于我提供的第一个链接不是“页面”而是产品,因此它不能以相同的方式运行。我相信WooCommerce在我的模板中使用标准的page.php来呈现产品页面。此代码包含:

<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package progression
 * @since progression 1.0
 */

get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>

    <?php the_content(); ?> 

    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'progression' ), 'after' => '</div>' ) ); ?>
<?php endwhile; // end of the loop. ?>      

<?php if(of_get_option('page_comments_default', '0')): ?><?php comments_template( '', true ); ?><?php endif; ?>

<?php get_footer(); ?>

WooCommerce中的产品没有“特色图片”,而是“产品图片”,我认为这是一回事。在任何情况下,我都无法在页面顶部显示标题图像。

有没有人知道如何解决这个问题?如果需要其他代码或说明,请告知我们。这个问题一直让我疯狂!

提前致谢!

更新:

我发现woocommerce中的单个产品页面使用以下模板(woocommerce / templates / single-product.php):

    <?php
    /**
     * The Template for displaying all single products.
     *
     * Override this template by copying it to yourtheme/woocommerce/single-product.php
     *
     * @author      WooThemes
     * @package     WooCommerce/Templates
     * @version     1.6.4
     */

    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

    get_header( 'shop' ); ?>
        <?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 while ( have_posts() ) : the_post(); ?>

                <?php wc_get_template_part( 'content', 'single-product' ); ?>

            <?php endwhile; // end of the loop. ?>

        <?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' );
        ?>

    <?php get_footer( 'shop' ); ?>

除此之外,正在调用标题图像显示(White Rock:page-title-progression.php):

<?php if(is_404() ): ?>
    <div id="page-title">
        <div class="width-container paged-title">
            <h1 class="page-title"><?php _e( '404 Page Not Found ', 'progression' ); ?></h1>
        </div>
        <div id="page-title-divider"></div>
    </div><!-- #page-title -->
    <div class="clearfix"></div>
    <?php $page_for_posts = get_option('page_for_posts'); ?>
    <?php if(has_post_thumbnail($page_for_posts)): ?>
        <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
        <script type='text/javascript'>

        jQuery(document).ready(function($) {  
            $("#page-title").backstretch([
                "<?php echo $image[0]; ?>"
                <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                    if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                        echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                    }

                    if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                        echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                    }
                }
                ?>
            ],{
                    fade: 750,
                    duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
             });
        });

        </script>
    <?php endif; ?>
<?php else: ?>

    <?php if(is_page()): ?>
        <?php
        global $wp_query;
        $thePostID = $wp_query->post->ID;
        ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <h1><?php the_title(); ?></h1>  
            </div>
        <div id="page-title-divider"></div>
        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php if(has_post_thumbnail()): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'progression-page-title'); ?>
            <script type='text/javascript'>
            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });
            </script>
        <?php endif; ?>
    <?php endif; ?>

    <?php if(is_home() || is_single() && 'portfolio' != get_post_type() && 'menu' != get_post_type() ): ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <?php $page_for_posts = get_option('page_for_posts'); ?>
                <h1 class="page-title"><?php echo get_the_title($page_for_posts); ?></h1>
            </div>
        <div id="page-title-divider"></div>
        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php if(has_post_thumbnail($page_for_posts)): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
            <script type='text/javascript'>

            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });

            </script>
        <?php endif; ?>
    <?php endif; ?>

    <?php if(is_archive() ): ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <h1 class="page-title">
                    <?php if ( is_day() ) : ?>
                    <?php printf( __( 'Archives: %s', 'progression' ), '<span>' . get_the_date() . '</span>' ); ?>
                    <?php elseif ( is_month() ) : ?>
                        <?php printf( __( 'Archives: %s', 'progression' ), '<span>' . get_the_date( 'F Y' ) . '</span>' ); ?>
                    <?php elseif ( is_year() ) : ?>
                        <?php printf( __( 'Archives: %s', 'progression' ), '<span>' . get_the_date( 'Y' ) . '</span>' ); ?>
                    <?php endif; ?>
                    <?php if ( is_tag() ) : ?>
                        <?php
                            printf( __( 'Tag: %s', 'progression' ), '<span>' . single_tag_title( '', false ) . '</span>' );
                        ?>
                    <?php endif; ?>
                    <?php if ( is_author() ) : ?>
                        <?php _e( 'Author Archives:', 'progression' ); ?>
                        <?php $user_info = get_userdata(1);
                              echo '' . $user_info->display_name . "\n";
                        ?>
                    <?php endif; ?>
                    <?php if(post_type_exists('menu') ) : ?>
                        <?php
                            printf( __( '%s', 'progression' ), '<span>' . single_cat_title( '', false ) . '</span>' );
                        ?>
                    <?php endif; ?>
                    </h1>
                </div>
            <div id="page-title-divider"></div>
        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php $page_for_posts = get_option('page_for_posts'); ?>
        <?php if(has_post_thumbnail($page_for_posts)): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
            <script type='text/javascript'>

            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });

            </script>
        <?php endif; ?>

    <?php endif; ?>

    <?php if(is_search() ): ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <h1 class="page-title"><?php printf( __( 'Search for: %s', 'progression' ), '<span>' . get_search_query() . '</span>' ); ?></h1></div>
        <div id="page-title-divider"></div>

        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php $page_for_posts = get_option('page_for_posts'); ?>
        <?php if(has_post_thumbnail($page_for_posts)): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
            <script type='text/javascript'>

            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });

            </script>
        <?php endif; ?>
    <?php endif; ?>

    <?php if(is_single() && 'portfolio' == get_post_type() ): ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <h1><?php the_title(); ?></h1>  
            </div>
        <div id="page-title-divider"></div>
        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php $page_for_posts = get_option('page_for_posts'); ?>
        <?php if(has_post_thumbnail($page_for_posts)): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
            <script type='text/javascript'>

            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });

            </script>
        <?php endif; ?>
    <?php endif; ?>



    <?php if(is_single() && 'menu' == get_post_type() ): ?>
        <div id="page-title">
            <div class="width-container paged-title">
                <h1><?php the_title(); ?></h1>  
            </div>
        <div id="page-title-divider"></div>
        </div><!-- #page-title -->
        <div class="clearfix"></div>
        <?php $page_for_posts = get_option('page_for_posts'); ?>
        <?php if(has_post_thumbnail($page_for_posts)): ?>
            <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($page_for_posts), 'progression-page-title'); ?>
            <script type='text/javascript'>

            jQuery(document).ready(function($) {  
                $("#page-title").backstretch([
                    "<?php echo $image[0]; ?>"
                    <?php if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                        if( kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-2', 'page', 'progression-page-title', $thePostID ) , '"';
                        }

                        if( kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) != "" ) {
                            echo ',"', kd_mfi_get_featured_image_url( 'featured-image-3', 'page', 'progression-page-title', $thePostID ) , '"';
                        }
                    }
                    ?>
                ],{
                        fade: 750,
                        duration: <?php echo of_get_option('slider_autoplay', 8000); ?>
                 });
            });

            </script>
        <?php endif; ?>
    <?php endif; ?>

<?php endif; ?>

我希望这会对这个问题有所了解!

2 个答案:

答案 0 :(得分:0)

标题图片未显示,因为以下div未出现在产品页面中:

<div class="backstretch" style="left: 0px; top: 0px; overflow: hidden; margin: 0px; padding: 0px; height: 248px; width: 1351px; z-index: -999998; position: absolute;">
    <img src="https://www.parisisrestaurant.com/wptest/wp-content/uploads/2013/03/DSC_0655-1600x300.jpg" style="position: absolute; margin: 0px; padding: 0px; border: none; width: 1351px; height: 253.3125px; max-width: none; z-index: -999999; top: -2.65625px; left: 0px;">
</div>

该div位于page-title标记下的<header> div中。

答案 1 :(得分:0)

只需要为产品页面创建一个新的if语句:{-1}}在page-title-progression.php文件中