我的页面是bewitcheryinc.com 我正在尝试重新安排我的主页。我需要切换促销区域(带有3个矩形的部分)和下面的文字。我需要首先显示文本,然后显示促销区域(带有3个矩形的部分)。我已经联系了主题支持,他们告诉我内容是动态的,尝试的唯一解决方案是用以下代码替换header.php。
<?php
/**
* Displays the header content
*
* @package Theme Freesia
* @subpackage Edge
* @since Edge 1.0
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<?php
$edge_settings = edge_get_theme_options(); ?>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<!-- Masthead ============================================= -->
<header id="masthead" class="site-header">
<?php if ( function_exists( 'the_custom_header_markup' ) ) {
if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
echo '<div class="custom-header">
<div class="custom-header-media">';
the_custom_header_markup();
echo '</div>
</div>';
}else{
if ( has_header_image() ) {?>
<a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" /> </a>
<?php }
}
} else { ?>
<a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" /> </a>
<?php } ?>
<div class="top-header">
<div class="container clearfix">
<?php
if( is_active_sidebar( 'edge_header_info' )) {
dynamic_sidebar( 'edge_header_info' );
}
if($edge_settings['edge_top_social_icons'] == 0):
echo '<div class="header-social-block">';
do_action('social_links');
echo '</div>'.'<!-- end .header-social-block -->';
endif;
do_action('edge_site_branding'); ?>
</div> <!-- end .container -->
</div> <!-- end .top-header -->
<!-- Main Header============================================= -->
<div id="sticky_header">
<div class="container clearfix">
<h3 class="nav-site-title">
<a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>"><?php bloginfo('name');?></a>
</h3>
<!-- end .nav-site-title -->
<!-- Main Nav ============================================= -->
<?php
if (has_nav_menu('primary')) { ?>
<?php $args = array(
'theme_location' => 'primary',
'container' => '',
'items_wrap' => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>',
); ?>
<nav id="site-navigation" class="main-navigation clearfix">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<span class="line-one"></span>
<span class="line-two"></span>
<span class="line-three"></span>
</button>
<!-- end .menu-toggle -->
<?php wp_nav_menu($args);//extract the content from apperance-> nav menu ?>
</nav> <!-- end #site-navigation -->
<?php } else {// extract the content from page menu only ?>
<nav id="site-navigation" class="main-navigation clearfix">
<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
<span class="line-one"></span>
<span class="line-two"></span>
<span class="line-three"></span>
</button>
<!-- end .menu-toggle -->
<?php wp_page_menu(array('menu_class' => 'menu', 'items_wrap' => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>')); ?>
</nav> <!-- end #site-navigation -->
<?php }
$search_form = $edge_settings['edge_search_custom_header'];
if (1 != $search_form) { ?>
<div id="search-toggle" class="header-search"></div>
<div id="search-box" class="clearfix">
<?php get_search_form();?>
</div> <!-- end #search-box -->
<?php }
echo '</div> <!-- end .container -->
</div> <!-- end #sticky_header -->';
$enable_slider = $edge_settings['edge_enable_slider'];
edge_slider_value();
if ($enable_slider=='frontpage'|| $enable_slider=='enitresite'){
if(is_front_page() && ($enable_slider=='frontpage') ) {
if($edge_settings['edge_slider_type'] == 'default_slider') {
edge_page_sliders();
}else{
if(class_exists('Edge_Plus_Features')):
edge_image_sliders();
endif;
}
}
if($enable_slider=='enitresite'){
if($edge_settings['edge_slider_type'] == 'default_slider') {
edge_page_sliders();
}else{
if(class_exists('Edge_Plus_Features')):
edge_image_sliders();
endif;
}
}
} ?>
</header> <!-- end #masthead -->
<!-- Main Page Start ============================================= -->
<div id="content">
<div class="container clearfix">
<?php
if(is_front_page()){
if( have_posts() ) {
while( have_posts() ) {
the_post();
get_template_part( 'content', get_post_format() );
}
} else { ?>
<h2 class="entry-title"> <?php esc_html_e( 'No Posts Found.', 'edge' ); ?> </h2>
<?php }
do_action('edge_display_frontpage_features');
}
if(!is_home()){?>
<div class="page-header">
<h1 class="page-title"><?php echo edge_header_title(); ?></h1>
<!-- .page-title -->
<?php edge_breadcrumb(); ?>
<!-- .breadcrumb -->
</div>
<!-- .page-header -->
<?php }
替换headr.php后,我必须添加以下css:
.home .entry-header, .home .entry-meta, section#post-417, .home .entry-footer {
display:none;
}
当我按照这些说明操作时,主页会将我的原始页面文本显示为带有&#34的博客文章;阅读更多&#34;标签,以及元标签。阅读更多链接链接回主页。我只想让首页显示我的页面标题,一些文字,然后是宣传图片框。
如果它有用,我相信当启用促销区域时,主题使用front-page-feature.php模板而不是索引页面。它在下面。
<?php
function edge_frontpage_features(){
$edge_settings = edge_get_theme_options();
if($edge_settings['edge_disable_features'] != 1){
$edge_features = '';
$edge_total_page_no = 0;
$edge_list_page = array();
for( $i = 1; $i <= $edge_settings['edge_total_features']; $i++ ){
if( isset ( $edge_settings['edge_frontpage_features_' . $i] ) && $edge_settings['edge_frontpage_features_' . $i] > 0 ){
$edge_total_page_no++;
$edge_list_page = array_merge( $edge_list_page, array( $edge_settings['edge_frontpage_features_' . $i] ) );
}
}
if ( !empty( $edge_list_page ) && $edge_total_page_no > 0 ) {
echo '<!-- Promotional Area ============================================= -->';
$edge_features .= '<div class="promonational-area">';
$get_featured_posts = new WP_Query(array(
'posts_per_page' => $edge_settings['edge_total_features'],
'post_type' => array('page'),
'post__in' => $edge_list_page,
'orderby' => 'post__in',
));
$edge_features .= '<div class="column clearfix">';
$j = 1;
while ($get_featured_posts->have_posts()):$get_featured_posts->the_post();
$attachment_id = get_post_thumbnail_id();
$image_attributes = wp_get_attachment_image_src($attachment_id,'pixgraphy_promotional_image');
$excerpt = get_the_excerpt();
$edge_features .= '<div class="three-column">';
if ($image_attributes) {
$edge_features .= '<div class="promonational-img" title="'.the_title('', '', false).'"' .' style="background-image:url(' ."'" .esc_url($image_attributes[0])."'" .')"> <a class="promonational-link" href="'.get_the_permalink().'"></a> ';
$edge_features .= '<div class="promonational-overlay">
<h4>'.get_the_title().'</h4></div></div>';
}
$edge_features .='</div><!-- end .three-column -->';
$j++;
endwhile;
$edge_features .='</div><!-- .end column-->';
$edge_features .='</div><!-- end .promonational-area -->';
}
echo $edge_features;
}
wp_reset_postdata();
}
add_action('edge_display_frontpage_features','edge_frontpage_features');
有人可以帮忙吗?我显然不熟悉PHP / WordPress。谢谢!
答案 0 :(得分:1)
我认为这样可行:
在index.php中移动
if(is_front_page()){
do_action('edge_display_frontpage_features');
}
之前
get_template_part( 'pagination', 'none' );
在header.php中。
这会将首页功能放在&#39; main&#39;之后。帖子主要部分的内容。现在您需要弄清楚如何为文本添加正确的帖子内容。目前似乎没有获取正确的帖子类型。它可能是帖子类型中的样本帖子。
但是文字应该是静态的还是随着您最近发布的内容而变化?如果它应该是静态的,您应该在管理信息中心的设置 - &gt;阅读和将首页设置为静态页面,然后您可以放入文本到该页面内容。