2017-04-19 67 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上它不是一个“代码编写的服务”,我发布此,因此它可能帮助别人