2

我正在制作一个基于二十二的自定义主题。我面临关于 woocommerce 商店页面的问题。我有一个可以正常工作的页面模板。但是,当我激活 woocommerce 插件并显示商店基本页面(使用我的自定义页面模板)时,它会删除我的所有自定义 div 和其他自定义内容。我使用了 woocommerce.php 和操作钩子,遵循了 woocommerce 文档。但它没有产生任何结果。这是我的页面模板代码。

    <?php
/**
 * Template Name: Front Page Template
 *
 * Description: A page template that provides a key component of WordPress as a CMS
 * by meeting the need for a carefully crafted introductory page. The front page template
 * in Twenty Twelve consists of a page content area for adding text, images, video --
 * anything you’d like -- followed by front-page-only widgets in one or two columns.
 *
 * @package WordPress
 * @subpackage Twenty_Twelve
 * @since Twenty Twelve 1.0
 */

get_header(); ?>

    <div id="primary" class="site-content">
        <div id="content" role="main">

 
    
    
   
<div class="rotator">
                <ul id="rotmenu">

                    
                    <?php
                        $recentposts=get_pages('number=5');
                       // echo $recentposts;
                        $ii=0;
                        if ($recentposts) {
                            
                            $ii=0;
                        //foreach($recentposts as $page) {
                        //setup_postdata($page);
                            for ($ii=1;$ii<=5;$ii=$ii+1){
                            //$ii=$ii+1;
                            
                                $title='r_slideshow_0'.$ii.'_title';
                                $image='r_slideshow_0'.$ii.'_uploader';
                                $details='e_slideshow_0'.$ii.'_textarea';
                                $link='r_slideshow_0'.$ii.'_link';
                               // echo $page;
                                // echo $title;
                                //echo $image;
                                //echo $details;
                                //echo of_get_option($image, 'no entry');
                        ?>

                            <li>
                                
                                
                                
                                <a href="<?php echo of_get_option($link, 'no entry');?>"><?php echo of_get_option($title, 'no entry');/*echo $page->post_title;*/ ?></a>
                                <div style="display:none;">
                                    <div class="info_image"><?php echo of_get_option($image, 'no entry');?></div>
                                    <div class="info_heading"><?php echo of_get_option($title, 'no entry'); ?></div>
                                    <div class="info_description">
                                       
                                        <?php echo of_get_option($details, 'no entry'); ?>
                                         <a href="<?php echo of_get_option($link, 'no entry');?>" class="more">Read Details >></a><br/>
                                     </div>
                                  </div>
                            </li>


                            <?php
                        //$ii=$ii+1;
                            
                        }
                        }
                        ?>      
                    </ul>
                      <div id="rot1">
                    <img src="" width="100%" height="300" class="bg" alt=""/>
                    <div class="heading">
                        <h1></h1>
                    </div>
                    <div class="description">
                        <p></p>

                    </div>    
                </div>
            </div>






                    
                    <!--#rotator on front static page-->
                    
                    
                    
                    
                    <?php 
                    if(of_get_option('boxchoice_radio', '0' )){
                        ?>
                        <!--box content-->
                     <div class="section_front_page group_front_page">
                         <div class="col_front_page span_1_of_3">
                                
                                      
                            <img src="<?php echo of_get_option('frontpage_boximage_01' ); ?>"style=" ">
                                <?php if(of_get_option('frontpage_textarea_01' ) && of_get_option('frontpage_textarea_01' )!='Default Text') 
                                {
                                    ?>
                                    
                               <?php echo of_get_option('frontpage_textarea_01' ); ?>
                                <?php } ?>
                                        
                                <br/>
                                <?php if(of_get_option('frontpage_linkarea_01' ) && of_get_option('frontpage_linkarea_01' )!='Default') 
                                {
                                    ?>
                                <a href="<?php echo of_get_option('frontpage_linkarea_01' ); ?>">Read More >></a>
                                <?php } ?>
                         </div>
                         <div class="col_front_page span_1_of_3">
                         
                           <img src="<?php echo of_get_option('frontpage_boximage_02' ); ?>" style="">
                                <?php if(of_get_option('frontpage_textarea_02' ) && of_get_option('frontpage_textarea_02' )!='Default Text') 
                                {
                                    ?>
                                    <p>
                               <?php echo of_get_option('frontpage_textarea_02' ); ?>
                                     </p>
                               <?php } ?>
                                <br/>
                                <?php if(of_get_option('frontpage_linkarea_02' ) && of_get_option('frontpage_linkarea_02' )!='Default') 
                                {
                                    ?>
                                <a href="<?php echo of_get_option('frontpage_linkarea_02' ); ?>">Read More >></a>
                                 <?php } ?>
                         </div>
                         <div class="col_front_page span_1_of_3">
                             <img src="<?php echo of_get_option('frontpage_boximage_03' ); ?>"style=" float:right; width:100%;" >
                            
                               
                               <br/>
                                <?php if(of_get_option('frontpage_textarea_03' ) && of_get_option('frontpage_textarea_03' )!='Default Text') 
                                {
                                    ?>
                               <?php echo of_get_option('frontpage_textarea_03' ); ?>
                               <?php } ?>
                               <?php if(of_get_option('frontpage_linkarea_03' ) && of_get_option('frontpage_linkarea_03' )!='Default') 
                                {
                                    ?>
                                <a href="<?php echo of_get_option('frontpage_linkarea_03' ); ?>">Read More >></a>
                              <?php } ?>
                                                               
                         </div>
                  </div>    
                    <!--#end of box content-->
                    <?php
                    }  //end of boxes
                    ?>
                    
                    <!--#end of box content-->
                    
                    <!--default content on page-->
            <?php while ( have_posts() ) : the_post(); ?>
                <?php if ( has_post_thumbnail() ) : ?>
                    <div class="entry-page-image">
                        <?php the_post_thumbnail(); ?>
                    </div><!-- .entry-page-image -->
                <?php endif; ?>

                <?php get_template_part( 'content', 'page' ); ?>

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

                                                     
                                        
                                        
        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_sidebar( 'front' ); ?>
<?php get_footer(); ?>

我在我的functions.php文件中使用了它来使它与woocommerce兼容,

remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);

add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
 
function my_theme_wrapper_start() {
  echo '<div id="main">';
}
 
function my_theme_wrapper_end() {
  echo '</div>';
}

但是,它没有用。只有产品在页面上显示为全宽,默认侧边栏位于其底部。

我需要一些帮助。你能给我一些想法吗?

4

2 回答 2

5

最好是你使用“模板覆盖”方法:

将主题文件夹中的 woocommerce/templates/ 文件夹复制到 yourtheme/woocommerce/

在该文件夹中,您可以根据自己的喜好修改 html 结构,它将代替 woocommerce 标准 html 模板使用。

完成后,打开这两个文件:

/wp-content/themes/your-theme/woocommerce/shop/wrapper-start.php
/wp-content/themes/your-theme/woocommerce/shop/wrapper-end.php

并修改 html 以匹配您的。

于 2013-01-15T13:53:17.183 回答
-1

有两种方法,一种是使用 woo commerce_content(),另一种是使用钩子,所以请按照第一种方法将 woo commerce 合并到您的主题中,如果您不遵循合并 woo commerce 到主题的文档,将对您的主题设计有害......

于 2013-08-17T09:45:05.947 回答