duannei0044 2015-02-08 19:49
浏览 45
已采纳

WordPress儿童主题include_once

i'm trying to create a child theme to override some functions in my parent theme

i have this in parent functions.php theme

 include_once('admin/functions-extended/fn-typography.php'); //User Typography

This is my try:

  include_once(get_stylesheet_directory().'admin/functions-extended/fn-typography.php' );

but not work

more details

i'm trying add custom fonts in this file but in child theme the code in parent fn-typography.php is

function mgm_get_google_fonts() {
// Google Font Defaults
$google_faces = array(
    "Abel" => "Abel",
    "Abril Fatface" => "Abril Fatface",
    "Aclonica" => "Aclonica",
    "Acme" => "Acme",
    "Actor" => "Actor",
    "Adamina" => "Adamina",
    "Advent Pro" => "Advent Pro",
    "Aguafina Script" => "Aguafina Script",
    "Aladin" => "Aladin",
    "Aldrich" => "Aldrich",
    "Alegreya" => "Alegreya",
    "Alegreya SC" => "Alegreya SC",
    "Alex Brush" => "Alex Brush",
    "Alfa Slab One" => "Alfa Slab One",
    "Alice" => "Alice",
    "Alike" => "Alike",
    "Alike Angular" => "Alike Angular",
    "Allan" => "Allan",
            );
return $google_faces;
   }

i want remove this fonts and add another fonts

  • 写回答

2条回答 默认 最新

  • doucou1892 2015-02-08 22:29
    关注

    In the code you show, mgm_get_google_fonts() is not actually loading fonts, but apparently providing a list of fonts for some other function to load.

    The comment in the parent function describes it as providing defaults, so implies that there is some way to override them. From looking through the parent functions.php, you can probably figure out how you can do that.

    For example, if the parent theme allows you to override this function, it will probably say something like:

    if ( !function_exists( 'mgm_get_google_fonts') {
        ...the function definition you have above...
    }
    

    This tests to see if you have defined a function of the same name in your child theme and uses yours if you have.

    If the parent theme doesn't do this, they you will need to look where mgm_get_google_fonts is called and track down how to override.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目