需要Wordpress主题PHP帮助
我使用高级Wordpress主题创建我的网站,当我使用自定义主题标题时,主题会自动将我的博客标题和社交图标放置在我上传到帖子中的全宽功能图形中。有关示例,请参见此处: 我想使标题和社交图标显示在全宽图形下方,如下所示: (请注意,我使用了一个滑块插件实现了这一点,但这不是一个选项,因为它会增加页面加载时间,并造成组织不良 我已经缩小了与functions.php文件中的头/社交图标相关的代码部分,并希望能够帮助修改它以显示我想要的内容,因为我对php了解甚少 与自定义标题相关的functions.php部分:需要Wordpress主题PHP帮助,php,wordpress,header,blogs,Php,Wordpress,Header,Blogs,我使用高级Wordpress主题创建我的网站,当我使用自定义主题标题时,主题会自动将我的博客标题和社交图标放置在我上传到帖子中的全宽功能图形中。有关示例,请参见此处: 我想使标题和社交图标显示在全宽图形下方,如下所示: (请注意,我使用了一个滑块插件实现了这一点,但这不是一个选项,因为它会增加页面加载时间,并造成组织不良 我已经缩小了与functions.php文件中的头/社交图标相关的代码部分,并希望能够帮助修改它以显示我想要的内容,因为我对php了解甚少 与自定义标题相关的functions
#-----------------------------------------------------------------#
# Custom page header
#-----------------------------------------------------------------#
if ( !function_exists( 'nectar_page_header' ) ) {
function nectar_page_header($postid) {
global $options;
global $post;
global $nectar_theme_skin;
$bg = get_post_meta($postid, '_nectar_header_bg', true);
$bg_color = get_post_meta($postid, '_nectar_header_bg_color', true);
$font_color = get_post_meta($postid, '_nectar_header_font_color', true);
$parallax_bg = get_post_meta($postid, '_nectar_header_parallax', true);
$title = get_post_meta($postid, '_nectar_header_title', true);
$subtitle = get_post_meta($postid, '_nectar_header_subtitle', true);
$height = get_post_meta($postid, '_nectar_header_bg_height', true);
$page_template = get_post_meta($postid, '_wp_page_template', true);
$display_sortable = get_post_meta($postid, 'nectar-metabox-portfolio-display-sortable', true);
$inline_filters = (!empty($options['portfolio_inline_filters']) && $options['portfolio_inline_filters'] == '1') ? '1' : '0';
$filters_id = (!empty($options['portfolio_inline_filters']) && $options['portfolio_inline_filters'] == '1') ? 'portfolio-filters-inline' : 'portfolio-filters';
$text_align = get_post_meta($postid, '_nectar_page_header_alignment', true);
$fullscreen_header = (!empty($options['blog_header_type']) && $options['blog_header_type'] == 'fullscreen' && is_singular('post')) ? true : false;
$bottom_shadow = get_post_meta($postid, '_nectar_header_bottom_shadow', true);
$bg_overlay = get_post_meta($postid, '_nectar_header_overlay', true);
(!empty($display_sortable) && $display_sortable == 'on') ? $display_sortable = '1' : $display_sortable = '0';
//incase no title is entered for portfolio, still show the filters
if( $page_template == 'template-portfolio.php' && empty($title)) $title = get_the_title($post->ID);
if( !empty($bg) || !empty($bg_color) ) {
(empty($bg)) ? $social_img_src = 'none' : $social_img_src = $bg;
(empty($bg)) ? $bg = 'none' : $bg = 'url('.$bg.')';
(empty($bg_color)) ? $bg_color = '#000' : $bg_color = $bg_color;
$height = (!empty($height)) ? preg_replace('/\s+/', '', $height) : $height;
$not_loaded_class = ($nectar_theme_skin != 'ascend') ? "not-loaded" : null;
$fullscreen_class = ($fullscreen_header == true) ? "fullscreen-header" : null;
$bottom_shadow_class = ($bottom_shadow == 'on') ? " bottom-shadow": null;
$bg_overlay_class = ($bg_overlay == 'on') ? " bg-overlay": null;
$ajax_page_loading = (!empty($options['ajax-page-loading']) && $options['ajax-page-loading'] == '1') ? true : false;
$wrapper_height_style = ($fullscreen_header == true && ($post->post_type == 'post' && is_single()) || $ajax_page_loading == false) ? null : 'style="height: '.$height.'px;"';
if(!empty($parallax_bg) && $parallax_bg == 'on') { echo '<div id="page-header-wrap" class="'.$fullscreen_class.'" '.$wrapper_height_style.'>'; } ?>
<div class="<?php echo $not_loaded_class . ' ' . $fullscreen_class . $bottom_shadow_class . $bg_overlay_class; ?>" id="page-header-bg" data-alignment="<?php echo (!empty($text_align)) ? $text_align : 'left' ; ?>" data-parallax="<?php echo (!empty($parallax_bg) && $parallax_bg == 'on') ? '1' : '0'; ?>" data-height="<?php echo (!empty($height)) ? $height : '350'; ?>" style="background-color: <?php echo $bg_color?>; background-image: <?php echo nectar_options_img($bg); ?>; height: <?php echo $height;?>px;">
<div class="container">
<?php
if($post->ID != 0 && $post->post_type && $post->post_type == 'portfolio') { ?>
<div class="row project-title">
<div class="container">
<div class="col span_6 section-title <?php if(empty($options['portfolio_social']) || $options['portfolio_social'] == 0 || empty($options['portfolio_date']) || $options['portfolio_date'] == 0 ) echo 'no-date'?>">
<h1><?php the_title(); ?></h1>
<?php
$options = get_option('salient');
$back_to_all_override = get_post_meta($post->ID, 'nectar-metabox-portfolio-parent-override', true);
if(empty($back_to_all_override)) $back_to_all_override = 'default';
//attempt to find parent portfolio page - if unsuccessful default to main portfolio page
global $post;
$terms = get_the_terms($post->id,"project-type");
$project_cat = null;
$portfolio_link = null;
if(empty($terms)) $terms = array('1' => (object) array('name' => 'nothing'));
foreach ( $terms as $term ) {
$project_cat = strtolower($term->name);
}
$page = get_page_by_title_search($project_cat);
if(empty($page)) $page = array( '0' => (object) array('ID' => 'nothing'));
$page_link = verify_portfolio_page($page[0]->ID);
//if a page has been found for the category
if(!empty($page_link) && $back_to_all_override == 'default') {
$portfolio_link = $page_link;
?>
<div id="portfolio-nav">
<ul>
<li id="all-items"><a href="<?php echo $portfolio_link; ?>"><i class="icon-salient-back-to-all"></i></a></li>
</ul>
<ul class="controls">
<li id="prev-link"><?php be_next_post_link('%link','<i class="icon-salient-left-arrow-thin"></i>',TRUE, null,'project-type'); ?></li>
<li id="next-link"><?php be_previous_post_link('%link','<i class="icon-salient-right-arrow-thin"></i>',TRUE, null, 'project-type'); ?></li>
</ul>
</div>
<?php }
//if no category page exists
else {
$portfolio_link = get_portfolio_page_link(get_the_ID());
if(!empty($options['main-portfolio-link'])) $portfolio_link = $options['main-portfolio-link'];
if($back_to_all_override != 'default') $portfolio_link = get_page_link($back_to_all_override); ?>
<div id="portfolio-nav">
<ul>
<li id="all-items"><a href="<?php echo $portfolio_link; ?>"><i class="icon-salient-back-to-all"></i></a></li>
</ul>
<ul class="controls">
<li id="prev-link"><?php next_post_link('%link','<i class="icon-salient-left-arrow-thin"></i>'); ?></li>
<li id="next-link"><?php previous_post_link('%link','<i class="icon-salient-right-arrow-thin"></i>'); ?></li>
</ul>
</div>
<?php } ?>
</div>
</div>
</div><!--/row-->
<?php } elseif($post->ID != 0 && $post->post_type == 'post' && is_single() ) {
// also set as an img for social sharing/
if($social_img_src != 'none') echo '<img class="hidden-social-img" src="'.$social_img_src.'" alt="'.get_the_title().'" />';
?>
<div class="row">
<div class="col span_6 section-title blog-title">
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php if(($post->post_type == 'post' && is_single()) && $fullscreen_header == true) { ?>
<div class="author-section">
<span class="meta-author vcard author">
<?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), 100 ); }?>
</span>
<div class="avatar-post-info">
<span class="fn"><?php the_author_posts_link(); ?></span>
<span class="meta-date date updated"><i><?php echo get_the_date(); ?></i></span>
</div>
</div>
<?php } ?>
<?php if($fullscreen_header != true) { ?>
<div id="single-below-header">
<span class="meta-author vcard author"><span class="fn"><?php echo __('By', NECTAR_THEME_NAME); ?> <?php the_author_posts_link(); ?></span></span>
<?php if( !empty($options['blog_social']) && $options['blog_social'] == 1) { ?>
<span class="meta-date date updated"><?php echo get_the_date(); ?></span>
<?php } ?>
<span class="meta-category"><?php the_category(', '); ?></span>
<span class="meta-comment-count"><a href="<?php comments_link(); ?>"><?php comments_number( __('No Comments', NECTAR_THEME_NAME), __('One Comment ', NECTAR_THEME_NAME), __('% Comments', NECTAR_THEME_NAME) ); ?></a></span>
</div><!--/single-below-header-->
<div id="single-meta" data-sharing="<?php echo ( !empty($options['blog_social']) && $options['blog_social'] == 1 ) ? '1' : '0'; ?>">
<ul>
<?php if( empty($options['blog_social']) || $options['blog_social'] == 0 ) { ?>
<li>
<?php echo '<span class="n-shortcode">'.nectar_love('return').'</span>'; ?>
</li>
<li>
<?php echo get_the_date(); ?>
</li>
<?php } ?>
</ul>
<?php if( !empty($options['blog_social']) && $options['blog_social'] == 1 ) {
echo '<div class="nectar-social">';
echo '<span class="n-shortcode">'.nectar_love('return').'</span>';
//facebook
if(!empty($options['blog-facebook-sharing']) && $options['blog-facebook-sharing'] == 1) {
echo "<a class='facebook-share nectar-sharing' href='#' title='".__('Share this', NECTAR_THEME_NAME)."'> <i class='icon-facebook'></i> <span class='count'></span></a>";
}
//twitter
if(!empty($options['blog-twitter-sharing']) && $options['blog-twitter-sharing'] == 1) {
echo "<a class='twitter-share nectar-sharing' href='#' title='".__('Tweet this', NECTAR_THEME_NAME)."'> <i class='icon-twitter'></i> <span class='count'></span></a>";
}
//google plus
if(!empty($options['blog-google-plus-sharing']) && $options['blog-google-plus-sharing'] == 1) {
echo "<a class='google-plus-share nectar-sharing-alt' href='#' title='".__('Share this', NECTAR_THEME_NAME)."'> <i class='icon-google-plus'></i> <span class='count'> ".GetGooglePlusShares(get_permalink($post->ID))." </span></a>";
}
//linkedIn
if(!empty($options['blog-linkedin-sharing']) && $options['blog-linkedin-sharing'] == 1) {
echo "<a class='linkedin-share nectar-sharing' href='#' title='".__('Share this', NECTAR_THEME_NAME)."'> <i class='icon-linkedin'></i> <span class='count'> </span></a>";
}
//pinterest
if(!empty($options['blog-pinterest-sharing']) && $options['blog-pinterest-sharing'] == 1) {
echo "<a class='pinterest-share nectar-sharing' href='#' title='".__('Pin this', NECTAR_THEME_NAME)."'> <i class='icon-pinterest'></i> <span class='count'></span></a>";
}
echo '</div>';
}
?>
</div><!--/single-meta-->
<?php } //end if theme skin default ?>
</div><!--/section-title-->
</div><!--/row-->
<?php //default
} else { ?>
<div class="row">
<div class="col span_6">
<h1><?php echo $title; ?></h1>
<span class="subheader"><?php echo $subtitle; ?></span>
</div>
<?php // portfolio filters
if( $page_template == 'template-portfolio.php' && $display_sortable == '1' && $inline_filters == '0') { ?>
<div id="<?php echo $filters_id;?>">
<a href="#" data-sortable-label="<?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] :'Sort Portfolio'; ?>" id="sort-portfolio"><span><?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] : __('Sort Portfolio',NECTAR_THEME_NAME); ?></span> <i class="icon-angle-down"></i></a>
<ul>
<li><a href="#" data-filter="*"><?php echo __('All', NECTAR_THEME_NAME); ?></a></li>
<?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'project-type', 'show_option_none' => '', 'walker' => new Walker_Portfolio_Filter())); ?>
</ul>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php if(($post->ID != 0 && $post->post_type == 'post' && is_single()) && $fullscreen_header == true) { ?>
<a href="#" class="section-down-arrow"><i class="icon-salient-down-arrow icon-default-style"> </i></a>
<?php } ?>
</div>
<?php if(!empty($parallax_bg) && $parallax_bg == 'on') { echo '</div>'; } ?>
<?php } else if( !empty($title)) { ?>
<div class="row page-header-no-bg" data-alignment="<?php echo (!empty($text_align)) ? $text_align : 'left' ; ?>">
<div class="container">
<div class="col span_12 section-title">
<h1><?php echo $title; ?><?php if(!empty($subtitle)) echo '<span>' . $subtitle . '</span>'; ?></h1>
<?php // portfolio filters
if( $page_template == 'template-portfolio.php' && $display_sortable == '1' && $inline_filters == '0') { ?>
<div id="<?php echo $filters_id;?>">
<a href="#" data-sortable-label="<?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] :'Sort Portfolio'; ?>" id="sort-portfolio"><span><?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] : __('Sort Portfolio',NECTAR_THEME_NAME); ?></span> <i class="icon-angle-down"></i></a>
<ul>
<li><a href="#" data-filter="*"><?php echo __('All', NECTAR_THEME_NAME); ?></a></li>
<?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'project-type', 'show_option_none' => '', 'walker' => new Walker_Portfolio_Filter())); ?>
</ul>
</div>
<?php } ?>
</div>
</div>
</div>
<?php }
}
}
function using_page_header($post_id){
global $post;
global $woocommerce;
if($woocommerce && is_shop() || $woocommerce && is_product_category() || $woocommerce && is_product_tag()) {
$header_title = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_title', true);
$header_bg = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_bg', true);
$header_bg_color = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_bg_color', true);
$disable_effect = get_post_meta(woocommerce_get_page_id('shop'), '_disable_transparent_header', true);
$force_effect = null;
}
else if(is_home() || is_archive()){
$header_title = get_post_meta(get_option('page_for_posts'), '_nectar_header_title', true);
$header_bg = get_post_meta(get_option('page_for_posts'), '_nectar_header_bg', true);
$header_bg_color = get_post_meta(get_option('page_for_posts'), '_nectar_header_bg_color', true);
$disable_effect = get_post_meta(get_option('page_for_posts'), '_disable_transparent_header', true);
$force_effect = null;
} else {
$header_title = get_post_meta($post->ID, '_nectar_header_title', true);
$header_bg = get_post_meta($post->ID, '_nectar_header_bg', true);
$header_bg_color = get_post_meta($post->ID, '_nectar_header_bg_color', true);
$disable_effect = get_post_meta($post->ID, '_disable_transparent_header', true);
$force_effect = get_post_meta($post->ID, '_force_transparent_header', true);
}
$pattern = get_shortcode_regex();
$using_applicable_shortcode = 0;
if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 0, $matches )) {
if($matches[0][0]){
if( strpos($matches[0][0],'nectar_slider') !== false && strpos($matches[0][0],'full_width="true"') !== false) {
if(empty($header_title)) $using_applicable_shortcode = 1;
} else {
$using_applicable_shortcode = 0;
}
}
}
//alternate header style
global $options;
if(!empty($options['blog_header_type']) && $options['blog_header_type'] == 'fullscreen' && is_singular('post')) $using_applicable_shortcode = 1;
//incase of search / tax / removing effect
if(is_search() || is_tax() || $disable_effect == 'on') { $using_applicable_shortcode = 0; $header_bg = 0; $header_bg_color = 0; }
//stop effect from WooCommerce single pages
global $woocommerce;
if($woocommerce && is_product()) { $using_applicable_shortcode = 0; $header_bg = 0; $header_bg_color = 0; }
//if forcing effect
if($force_effect == 'on' && (!is_search() && !is_tax()) ) { $using_applicable_shortcode = 1; }
$the_verdict = (!empty($header_bg_color) || !empty($header_bg) || $using_applicable_shortcode) ? true : false;
return $the_verdict;
}
function using_nectar_slider(){
global $post;
global $woocommerce;
if($woocommerce && is_shop() || $woocommerce && is_product_category() || $woocommerce && is_product_tag()) {
$header_title = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_title', true);
$header_bg = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_bg', true);
$header_bg_color = get_post_meta(woocommerce_get_page_id('shop'), '_nectar_header_bg_color', true);
}
else if(is_home() || is_archive()){
$header_title = get_post_meta(get_option('page_for_posts'), '_nectar_header_title', true);
$header_bg = get_post_meta(get_option('page_for_posts'), '_nectar_header_bg', true);
$header_bg_color = get_post_meta(get_option('page_for_posts'), '_nectar_header_bg_color', true);
} else {
$header_title = get_post_meta($post->ID, '_nectar_header_title', true);
$header_bg = get_post_meta($post->ID, '_nectar_header_bg', true);
$header_bg_color = get_post_meta($post->ID, '_nectar_header_bg_color', true);
}
$pattern = get_shortcode_regex();
$using_fullwidth_slider = 0;
if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 0, $matches )) {
if($matches[0][0]){
if( strpos($matches[0][0],'nectar_slider') !== false && strpos($matches[0][0],'full_width="true"') !== false
|| strpos($matches[0][0],' type="full_width_content"') !== false && strpos($matches[0][0],'nectar_slider') !== false && strpos($matches[0][0],'[vc_column width="1/1"') !== false ) {
$using_fullwidth_slider = 1;
} else {
$using_fullwidth_slider = 0;
}
}
}
//incase of search
if(is_search() || is_tax()) $using_fullwidth_slider = 0;
//stop effect from WooCommerce single pages
global $woocommerce;
if($woocommerce && is_product()) $using_fullwidth_slider = 0;
$the_verdict = (empty($header_title) && empty($header_bg) && empty($header_bg_color) && $using_fullwidth_slider) ? true : false;
return $the_verdict;
}
#-----------------------------------------------------------------#
#自定义页眉
#-----------------------------------------------------------------#
如果(!function_存在('nectar_page_header')){
函数nectar_页面_标题($posted){
全球美元期权;
全球$员额;
全球$nectar_主题_皮肤;
$bg=get_post_meta($postid,'u nectar_header_bg',true);
$bg_color=get_post_meta($postid,''u nectar_header'u bg_color',true);
$font\u color=get\u post\u meta($postid,'.'u nectar\u header\u font\u color',true);
$parallax_bg=get_post_meta($postid,'u nectar_header_parallax',true);
$title=get_post_meta($posted,'u nectar_header_title',true);
$subtitle=get_post_meta($postid,'u nectar_header_subtitle',true);
$height=get_post_meta($postid,'u nectar'u header'u bg_height',true);
$page_template=get_post_meta($posted,'.'wp_page_template',true);
$display\u sortable=get\u post\u meta($postid,'nectar metabox portfolio display sortable',true);
$inline_filters=(!empty($options['portfolio_inline_filters'])和$options['portfolio_inline_filters']=='1')?'1':'0';
$filters\u id=(!empty($options['portfolio\u inline\u filters'])和&$options['portfolio\u inline\u filters']=='1')?'portfolio filters inline':'portfolio filters';
$text\u align=get\u post\u meta($postid,'.'u nectar\u page\u header\u align',true);
$fullscreen\u header=(!empty($options['blog\u header\u type'])和$options['blog\u header\u type']='fullscreen'&是单数('post')?真:假;
$bottom\u shadow=get\u post\u meta($postid,'.'u nectar\u header\u bottom\u shadow',true);
$bg_overlay=get_post_meta($postid,'u nectar_header_overlay',true);
(!empty($display_sortable)&&$display_sortable='on')?$display_sortable='1':$display_sortable='0';
//如果没有为公文包输入标题,仍然显示过滤器
如果($page_template=='template portfolio.php'&&empty($title))$title=get_标题($post->ID);
如果(!empty($bg)| |!empty($bg_color)){
(空($bg))?$social\u img\u src='none':$social\u img\u src=$bg;
(空($bg))?$bg=‘无’:$bg=‘url(‘.$bg’)’;
(空($bg_color))?$bg_color='000':$bg_color=$bg_color;
$height=(!empty($height))?preg_replace('/\s+/',''$height):$height;
$not_loaded_class=($nectar_theme_skin!='ascend')?“not loaded”:null;
$fullscreen\u class=($fullscreen\u header==true)?“fullscreen header”:null;
$bottom\u shadow\u class=($bottom\u shadow=='on')?“bottom shadow”:null;
$bg_overlay_class=($bg_overlay=='on')?“bg overlay”:null;
$ajax\u page\u load=(!empty($options['ajax-page-load'])和&$options['ajax-page-load']=='1')?true:false;
$wrapper_height_style=($fullscreen_header==true&&($post->post_type=='post'&&is_single())| |$ajax_page_loading==false)?null:'style=“height:”.$height.px;”;
如果(!empty($parallax_bg)&&($parallax_bg=='on'){echo';}?>
在您的站点中,博客标题和社交图标的div容器似乎嵌套在id=“page header bg”的div中,而它应该位于类为“container wrap”的div中
看起来这是在你的主题中完成的,所以最好的办法是从“greyLIME HD Launcher主题”中复制头代码然后将LIME一词替换为ICE和相应的社交链接请缩小您的问题范围;例如,使用Chrome开发工具或类似工具检查您的页面,看看是什么导致了不一致。只需发布所有代码,并期望人们“注意调试”通过它将不会工作,我担心。如果你已经阅读了问题,你会看到没有问题,代码需要重组/安排,因为我缺乏php知识,我不想错过代码中的重要元素,所以提供了所有。我想这将比粘贴通常情况下没有足够的代码要好,如果你谢谢你给我一个建设性的回答,查了一下这些部门的名字和工作