主页上没有侧栏显示为什么不呢?

时间:2015-03-10 15:41:17

标签: wordpress wordpress-theming

小工具没有显示在主页上我在我的wordpress中将主页设置为首页,并且已经注册了自定义侧边栏,但正如您在主页上看到的那样,它们上没有侧边栏。

http://locosurfing.com/

    register_sidebar( array(
        'id'    =>'homepage-sidebar1',
        'name' => __( 'Home Page 1', 'MX' ),
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="widget-title">',
        'after_title' => '</h4>'
    ));

Which does indead show up in the widget area but I am trying to call the it with in the theme of index.php

Index.php 
        <?php
        /**
         * The main template file.
         *
         * This is the most generic template file in a WordPress theme
         * and one of the two required files for a theme
         *
         * @since MX 1.0
         */

        global $blog_style;

        get_header();

        // get layout, sidebar
        if(((is_home() && !is_front_page()) || is_category()|| is_tag() || is_date()) && (intval(get_option('page_for_posts')) > 0) ) {
            //when you use custom page for blog will use the page layout
            $layout = mx_get_page_layout(get_option('page_for_posts'));
            $sidebar_name = mx_get_post_meta_key('sidebar-type', get_option('page_for_posts'));
            $blog_style = mx_get_options_key('blog-post-show-style');
            if($sidebar_name == ""){
                $sidebar_name = "0";
            }
        }else{
            // index default will use global layout 
            $layout = mx_get_page_layout('global'); 
            $blog_style = mx_get_options_key('blog-post-show-style');
            $sidebar_name = '0';
        }

        ?>
        <div id="main" class="container">
            <div class="row">
                <?php if($layout == 2) { ?> 
                <aside class="col-md-3 col-sm-4"><?php generated_dynamic_sidebar($sidebar_name); ?></aside>
                <?php } ?>
                <section class="<?php echo $layout == 1 ? 'col-md-12 col-sm-12' : 'col-md-9 col-sm-8'; ?>">
                <?php
                    if (have_posts() ) {
                        // Start the Loop.
                        while ( have_posts() ) { 
                            the_post();
                            /*
                             * Include the post format-specific template for the content. If you want to
                             * use this in a child theme, then include a file called called content-___.php
                             * (where ___ is the post format) and that will be used instead.
                             */
                            get_template_part( 'content', get_post_format() );
                        }
                        mx_content_pagination('nav-bottom' , 'pagination-centered');
                    }else{
                        get_template_part( 'content', 'none' );
                    }
                ?>
                </section>

                <?php get_sidebar('homepage1'); ?>
                <?php if($layout == 3) { ?> 
                <aside class="col-md-3 col-sm-4"><?php generated_dynamic_sidebar($sidebar_name); ?></aside>
                <?php } ?> 
           <?php dynamic_sidebar('Home Page 1' ); ?>
            </div>
        </div>
        <?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

尝试使用侧边栏ID而不是名称。

改变这个:

<?php dynamic_sidebar('Home Page 1' ); ?>

对此:

<?php dynamic_sidebar('homepage-sidebar1' ); ?>
相关问题