【发布时间】:2018-02-19 07:27:48
【问题描述】:
我试图通过自定义 php 模板从我的 wordpress 模板页面中删除页眉和页脚,但希望保留主题的原始样式。 我已成功删除页脚,但卡在页眉上,我所做的所有调整都失去了样式或出现空白屏幕。
<?php
/**
* Template Name: No Header or Footer
* This template will only display the content you entered in the page editor
*/
?>
<?php
get_header();
if (have_posts()) : the_post();
?>
<div class="mainrows">
<div class="large-12 columns">
<div class="leftside fullwidth">
<?php
if(of_get_option('headertype')!='header3'){ $goni = "0";} else { $goni = "0";}
$bgattachment = get_post_meta(get_the_ID(), '_az_header_bg', true);
$bgtext = get_post_meta(get_the_ID(), 'titleofimg', true);
if(($bgattachment)&&(of_get_option('headertype')=='header3')){ $klaz = ";margin-top:-70px!important"; } else { $klaz = '';}
if($bgattachment){
echo '<div class="wpb_wrapper" style="margin-top:'.$goni.'px'.$klaz.'"><div class="wpb_text_column wpb_content_element ">';if($bgtext!=""){ echo '<div class="txtwr"><h1>'.$bgtext.'</h1>';} echo '<img src="'.$bgattachment.'" style="margin:0 auto!important;float:none;display:block;text-align:center;width:100%" class="phoneup" alt="" />';if($bgtext!=""){ echo '</div>';} echo '</div></div>';
}
echo '<div class="wrap1170 inwrap">';
if (getmb("hidetitle") != 'yes') {
$bgattachment = get_post_meta(get_the_ID(), '_az_header_bg', true);
if(!$bgattachment){
?>
<h1 style="margin-bottom:15px;margin-top:40px"><?php the_title(); ?></h1>
<?php
}
} the_content();?>
</div>
</div>
</div>
<?php
endif;
?>
【问题讨论】:
-
确保你保留
<?php wp_head(); ?>这就是包含样式的方式 -
对于它的价值,我认为这个问题已经因为错误的原因而被关闭。无论这是一个好问题、经过充分研究还是对未来的用户有帮助,都有待商榷,但对于任何了解 WordPress 中高级水平的人来说,这一点都非常清楚。为了认为它不清楚,人们必须不熟悉 WP 生态系统和页面生命周期,并且在我看来,在这种情况下,人们应该避免投票结束这个问题。因此,我提名重新开放的问题。
标签: php css wordpress templates