首页 文章

Woo-commerce商店页面删除自定义DIV

提问于
浏览
2

我正在制作一个基于二十世界的自定义主题 . 我正面临着关于woocommerce商店页面的问题 . 我有一个工作正常的页面模板 . 但是,当我激活woocommerce插件并显示商店基页(使用我的自定义页面模板)时,它会删除我所有的自定义div和其他自定义内容 . 我使用woocommerce.php和动作挂钩跟随woocommerce documentation . 但它没有产生任何结果 . 这是我的页面模板代码 .

<?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>
</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 } ?>
<?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 } ?>
<?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%;" >
<?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>';
}

但是,它没有用 . 只有产品在页面上显示跨越整个宽度,默认侧边栏位于其底部 .

我需要一些帮助 . 你能给我任何想法吗?

2 回答

  • -1

    最好的是你使用“template overwrite”方法:

    将主题文件夹中的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以匹配你的 .

  • 5

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

相关问题