2017-04-19 138 views
-1

我使用Wordpress「Edge」主題。有了這個主題的網站名稱有H1標籤,我想刪除它們。請參閱https://www.archlogo.com/三角形標誌下的網站名稱。問題是那些標籤在functions.php文件中,我不知道如何使用它(我對PHP沒有任何瞭解,以及如何覆蓋父主題函數)。下面是代碼在function.php包括的H1部分:刪除functions.php中的h1標籤(使用兒童主題)

/******************* Edge Header Display *************************/ 
function edge_header_display(){ 
    $edge_settings = edge_get_theme_options(); 
    $header_display = $edge_settings['edge_header_display']; 
    if ($header_display == 'header_text') { ?> 
     <div id="site-branding"> 
     <?php if(is_home() || is_front_page()){ ?> 
     <h1 id="site-title"> <?php }else{?> <h2 id="site-title"> <?php } ?> 
      <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a> 
     <?php if(is_home() || is_front_page() || is_search()){ ?> 
     </h1> <!-- end .site-title --> 
     <?php } else { ?> </h2> <!-- end .site-title --> <?php } 
     $site_description = get_bloginfo('description', 'display'); 
     if($site_description){?> 
     <p id ="site-description"> <?php bloginfo('description');?> </p> <!-- end #site-description --> 
     <?php } ?> 
     </div> <!-- end #site-branding --> 
     <?php 
    } elseif ($header_display == 'header_logo') { ?> 
     <div id="site-branding"> <?php edge_the_custom_logo(); ?></div> <!-- end #site-branding --> 
     <?php } elseif ($header_display == 'show_both'){ ?> 
     <div id="site-branding"> <?php edge_the_custom_logo(); ?></a> 
     <?php if(is_home() || is_front_page()){ ?> 
     <h1 id="site-title"> <?php }else{?> <h2 id="site-title"> <?php } ?> 
      <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a> 
      <?php if(is_home() || is_front_page()){ ?> </h1> <!-- end .site-title --> 
     <?php }else{ ?> </h2> <!-- end .site-title --> 
     <?php } 
     $site_description = get_bloginfo('description', 'display'); 
      if($site_description){?> 
      <p id ="site-description"> <?php bloginfo('description');?> </p><!-- end #site-description --> 
     <?php } ?> 
     </div> <!-- end #site-branding --> 
     <?php } 
} 

你知道如何刪除這些H1標籤?

回答

0

我試圖自己管理它。我不知道如果這個代碼是最好的,但它s工作:

<?php 
function child_remove_parent_function() { 
    remove_action('edge_site_branding', 'edge_header_display'); 
} 
add_action('wp_loaded', 'child_remove_parent_function'); 
?> 



<?php 
function my_parent_theme_function() { 
     $edge_settings = edge_get_theme_options(); 
     $header_display = $edge_settings['edge_header_display']; 
    if ($header_display == 'header_text') { ?> 
     <div id="site-branding"> 
     <?php if(is_home() || is_front_page()){ ?> 
     <div id="site-title"> <?php }else{?> <div id="site-title"> <?php } ?> 
      <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a> 
     <?php if(is_home() || is_front_page() || is_search()){ ?> 
     </div> <!-- end .site-title --> 
     <?php } else { ?> </div> <!-- end .site-title --> <?php } 
     $site_description = get_bloginfo('description', 'display'); 
     if($site_description){?> 
     <p id ="site-description"> <?php bloginfo('description');?> </p> <!-- end #site-description --> 
     <?php } ?> 
     </div> <!-- end #site-branding --> 
     <?php 
    } elseif ($header_display == 'header_logo') { ?> 
     <div id="site-branding"> <?php edge_the_custom_logo(); ?></div> <!-- end #site-branding --> 
     <?php } elseif ($header_display == 'show_both'){ ?> 
     <div id="site-branding"> <?php edge_the_custom_logo(); ?></a> 
     <?php if(is_home() || is_front_page()){ ?> 
     <div id="site-title"> <?php }else{?> <div id="site-title"> <?php } ?> 
      <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" rel="home"> <?php bloginfo('name');?> </a> 
      <?php if(is_home() || is_front_page()){ ?> </div> <!-- end .site-title --> 
     <?php }else{ ?> </div> <!-- end .site-title --> 
     <?php } 
     $site_description = get_bloginfo('description', 'display'); 
      if($site_description){?> 
      <p id ="site-description"> <?php bloginfo('description');?> </p><!-- end #site-description --> 
     <?php } ?> 
     </div> <!-- end #site-branding --> 
     <?php } 
} 
add_action('wp_head', 'my_parent_theme_function'); 
?> 

即使它似乎StackOverflow上它不是一個「代碼編寫的服務」,我發佈此,因此它可能幫助別人