WordPress页面模板删除侧边栏

时间:2016-02-17 06:17:19

标签: php css wordpress wordpress-theming

使用Ambition的子主题版本。由于某种原因,侧边栏显示在底部。如何编辑子主题或页面模板以使侧栏不显示。

以下是实例的链接:http://businessblessed.com/specialoffers/sales-pages/

以下是页面模板代码:

<?php
/*
Template Name: SQ w Img 2step
*/
?>
<?php
/**
 * This file displays page with no sidebar.
 *
 * @package Theme Horse
 * @subpackage Ambition
 * @since Ambition 1.0
 */
?>

<!DOCTYPE html>
<!--[if IE 7 ]>    <html lang="cs" class="ie7 no-js"> <![endif]-->
<!--[if IE 8 ]>    <html lang="cs" class="ie8 no-js"> <![endif]-->
<!--[if IE 9 ]>    <html lang="cs" class="ie9 no-js"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="cs" class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
    <title>GiveAway</title>
    <link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,400italic,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/css/style.css?v=1" media="screen, projection" />
    <link rel="stylesheet" href="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/css/print.css?v=1" media="print" />
    <link rel="shortcut icon" href="./favicon.ico" />
    <script>document.documentElement.className = document.documentElement.className.replace('no-js', 'js');</script>
</head>
<body class="page-subpage">
    <div id="main">
        <div class="row-main">
            <div class="col col-book">
                <a href="#"><img src="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/img/book.png" alt="book" /></a>
            </div>
            <div class="col col-content">
                <div class="in">
                    <p class="read-this"><?php single_post_title(); ?></p>
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content( ); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>​
                        </div>
                    </form>
                    <p class="secure">Your Information is 100% Secure And Will Never Be Shared With Anyone.</p>
                    <p class="legal"><a href="#">Legal Information</a></p>
                </div>
            </div>
        </div>
    </div>
    <!--[if lte IE 8 ]>
        <img src="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/img/bg.jpg" alt="" class="bg-ie" />
    <![endif]-->

    <script src="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/js/jquery.js?v=1"></script>
    <script src="http://businessblessed.com/wp-content/themes/virtue-child/squeeze-page-w-prodImage-2step-optin/js/app.js?v=1"></script>
    <script>
        App.run({})
    </script>
</body>
</html>

我还找到了一个&#34;没有侧边栏&#34;父主题内的模板,但我不确定是否可以应用它。

<?php
/**
* This file displays page with no sidebar.
*
* @package Theme Horse
* @subpackage Ambition
* @since Ambition 1.0
*/
?>
<?php
/**
* ambition_before_loop_content
 *
 * HOOKED_FUNCTION_NAME PRIORITY
 *
 * ambition_loop_before 10
*/
do_action( 'ambition_before_loop_content' );
/**
* ambition_loop_content
 *
 * HOOKED_FUNCTION_NAME PRIORITY
 *
 * ambition_theloop 10
*/
do_action( 'ambition_loop_content' );
/**
* ambition_after_loop_content
 *
 * HOOKED_FUNCTION_NAME PRIORITY
 *
 * ambition_next_previous 5
 * ambition_loop_after 10
*/
do_action( 'ambition_after_loop_content' );
?>

2 个答案:

答案 0 :(得分:0)

调试the_content() var_dump(the_content());并检查侧边栏数据,

另外你做错了,只有身体后面的数据你必须在模板文件中写。

答案 1 :(得分:0)

每个WordPress主题都提供带有侧边栏的页面模板以及没有侧边栏。

在这里,您可以轻松地使用没有侧边栏的页面模板,只需将其复制到侧栏中,这将是正确的方法。

通常WordPress使用get_sidebar()函数来显示侧边栏,因此请检查并将其从模板中删除,或者可以使用以下钩子:

如果添加到子主题的functions.php文件中,这将删除TwentyTen主题注册的页脚侧边栏。

function remove_some_widgets(){
    // Unregister some of the TwentyTen sidebars
    unregister_sidebar( 'first-footer-widget-area' );
    unregister_sidebar( 'second-footer-widget-area' );
}
add_action( 'widgets_init', 'remove_some_widgets', 11 );

如果这不起作用,那么你可以简单地使用css隐藏侧栏,方法是将body栏隐藏起来,这样侧边栏只会隐藏在特定的页面中,例如:

.sales_page aside {
  display : none;
}

但这肯定是最后一个选择。

相关问题