dongyan7988 2014-03-08 03:16
浏览 57
已采纳

从子主题中的“functions.php”中删除代码

I am trying to remove some lines from function.php in Wordpress without making this permanent. My initial thought was to use a child theme. I understand that if you add "functions.php" as a child, it can be used to modify the parents function. Any recommendations? Thanks in advance for your support!!!

This is the code I want to target:

function top_bar_front_end_menu(){
$top_bar_status= esc_html ( get_option('wp_estate_enable_top_bar','') );
if($top_bar_status=='yes'){
    $current_user = wp_get_current_user();
    $username=$current_user->user_login ;$pages = get_pages(array(
        'meta_key' => '_wp_page_template',
        'meta_value' => 'user-dashboard-add.php'
    ));

    if( $pages ){
        $add_link = get_permalink( $pages[0]->ID);
    }else{
        $add_link='';
    }

    $pages = get_pages(array(
        'meta_key' => '_wp_page_template',
        'meta_value' => 'user-dashboard-profile.php'
            ));

    if( $pages ){
        $dash_profile = get_permalink( $pages[0]->ID);
    }else{
        $dash_profile=home_url();
    }   

    $dash_link =   get_dashboard_link();
    print'<div class="top-user-menu-wrapper">
        <div class="top-user-menu">
            <div class="wellcome-user">';

                $show_user_not_logged_in='';
                $show_user_logged_in='';
                if ( is_user_logged_in() ) { 
                    $show_user_not_logged_in='geohide' ; 
                }else{
                     $show_user_logged_in='geohide';
                }

                 $paid_submission_status    = esc_html ( get_option('wp_estate_paid_submission','') ); 

                 print '
                    <div id="user_logged_in" class="'.$show_user_logged_in.'">';    
                    if($dash_link!=''){
                        print ' <a href="'.$dash_link.'">'.__('My Properties','wpestate').'</a> | ';
                    }else{
                        print '<a href="'.$dash_profile.'">' .__('My Profile','wpestate').'</a> | ';
                    }

                    if($add_link!=''){
                        print '<a href="'.$add_link.'">' .__('List a Property','wpestate').'</a> | ';
                    } 

                    print'
                    <a href="'.wp_logout_url().'">'.__('Log Out','wpestate').'</a>
                    </div>';  



                    $front_end_register =   esc_html( get_option('wp_estate_front_end_register','') );
                    $front_end_login    =   esc_html( get_option('wp_estate_front_end_login ','') );
                    print '
                    <div id="user_not_logged_in" class="'.$show_user_not_logged_in.'">  
                    <a href="'.$front_end_login.'">'.__('Login','wpestate').'</a> |    
                    <a href="'.$front_end_register.'">'.__('Register','wpestate').'</a> 
                    </div>';


                print'
            </div>
        </div>
    </div>';

} 

}

  • 写回答

1条回答 默认 最新

  • dongpigui8898 2014-03-08 03:20
    关注

    Yes, the recommendation would be to use the child theme.

    style.css

    /*
     Theme Name:   My Child Theme
     Description:  My Child Theme's description
     Author:       John Doe
     Author URI:   http://example.com
     Template:     child-theme
     Version:      1.0.0
    */
    
    @import url("../parent-theme/style.css");
    

    Then create a functions.php in child theme.

    However, the next part is that you're wanting to replace some code, which should not be done, instead you should remove it's action/filter hook that it has implemented :

    remove_action( $tag, $function_to_remove, $priority );
    

    Or if it was added as a filter:

    remove_filter( $tag, $function_to_remove, $priority ); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料