当前位置: 首页 > 知识库问答 >
问题:

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

浦德明
2023-03-14

更新

这是一个专门针对几个if项目的问题,因此,如果需要,请询问更多细节,我将尽力提供。

问题:我使用的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个答案

沈成天
2023-03-14

只需要为产品页面创建一个新的if语句:

裴俊智
2023-03-14

标题图像未出现,因为以下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-titlediv的下方。

 类似资料:
  • 我一直在我的笔记本电脑上使用lwjgl和GLSL 1.3进行一个项目。我的着色器在我的笔记本电脑上编译得很好,但是,当尝试在我的桌面上编译相同的着色器时,它有一个更新的显卡,我收到一个错误,说明着色器无法编译,因为着色器中存在错误。但是,着色器日志不会输出任何错误。我认为GLSL向后兼容它自己。 返回 我假设它与标准的GLSL 3.30相同。这是一个示例vertandfrag着色器,它适用于我的笔

  • 我们在堆栈中使用Kafka、Kafka连接和模式注册表。版本为2.8.1(融合6.2.1)。我们使用Kafka connect的配置(key.converter和value.converter),其值为:io.confluent.connect.avro.AvroConverter。 它自动注册主题的新模式。但有一个问题,AvroConverter没有为新模式指定主题级兼容性,当我们试图通过RES

  • 当我尝试sbt构建我的项目时,项目构建失败,出现“Extracting product structure failed”错误。我怀疑一些与我使用的Alpakka和Akka版本有关的东西。 下面是我的build.sbt文件: gael:下面是来自Intellij的错误消息的图像 运行时,我得到以下错误堆栈:

  • 根据Artem Bilan在这篇random gitter线程中的说法,Spring-Boot2仅与spring-kafka 2.1.x兼容。我找不到任何文件说明这一点。 考虑到所有这些,这是我唯一的选择: > 升级到kafka 1.0,因为spring-kafka 2.1仅与kafka 1.0兼容。 是否存在允许Spring-Boot2和Spring-Kafka旧版本之间兼容的东西?

  • 3.1 可以在什么样的硬件系统上运行? Debian GNU/Linux 包含所有程序的完整源代码, 因此可以在所有Linux内核支持的硬件系统上运行; 详见 Linux FAQ. Debian GNU/Linux 现在的版本是 8, 包括在以下硬件系统上运行的完整的源代码和二进制程序: i386: 指基于 Intel 和兼容处理器的 PC 机,包括Intel的 386, 486, Pentium

  • 我们在div里放一个img,发现: 在html和html5中,div的长宽是不同的,后者的高度要超过几个像素。 比如说,下面这个是html的。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css">