2016-02-17 163 views
0

使用Ambition的子主題版本。出於某種原因,側邊欄顯示在底部。如何編輯子主題或頁面模板以使側欄不顯示。WordPress頁面模板刪除邊欄

這裏是鏈接到的活生生的例子: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> 

我還發現父主題中「無文」的模板,但我不確定它是否可以應用。

<?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'); 
?> 

回答

0

調試the_content() var_dump(the_content());和檢查側欄數據,

你也做錯了,只有你在模板文件中寫入人體後的數據。

+0

「調試the_content()var_dump(the_content());並檢查側邊欄數據,」我不知道這意味着什麼。我不會說PHP。 – ELF

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的側邊欄:

.sales_page aside { 
    display : none; 
} 

但當然這應該是最後的選擇。