2015-05-26 56 views
2

我在WordPress的Aaron儿童主题中的功能有问题。我的部分问题在Overwrite parent functions in child function.php WordPress中得到了解答,但我无法使徽标以更大的尺寸工作。为了缩小范围并找出问题,我排除了很多代码。我发现,WordPress主题中没有显示儿童主题中的功能。这是函数:功能没有出现在儿童主题WordPress

/* Site Logo */ 
function add_site_icon_support() { 
    $args = array(
    'header-text' => array(
     'Site Title Here', 
     'Your site description goes here.', 
    ), 
    'size' => 'medium', 
); 
    add_theme_support('site-logo', $args); 
} 
add_action('after_setup_theme', 'add_site_icon_support'); 

我测试了它在父主题将它添加到的functions.php和它的作品。因此,我想知道如何使它在儿童主题中工作?

它与父主题中的这个功能有关吗?

function aaron_setup() { 
    /* 
    * Make theme available for translation. 
    * Translations can be filed in the /languages/ directory. 
    * If you're building a theme based on aaron, use a find and replace 
    * to change 'aaron' to the name of your theme in all the template files 
    */ 
    load_theme_textdomain('aaron', get_template_directory() . '/languages'); 
    // Add default posts and comments RSS feed links to head. 
    add_theme_support('automatic-feed-links'); 
    add_theme_support('woocommerce'); 
    add_theme_support('jetpack-responsive-videos'); 
    add_editor_style(); 
    add_theme_support('post-thumbnails'); 
    add_image_size('aaron-featured-posts-thumb', 360, 300); 
    add_theme_support('title-tag'); 
    register_nav_menus(array(
    'header' => __('Primary Menu', 'aaron'), 
    'social' => __('Social Menu', 'aaron'), 
)); 
    /* 
    * Switch default core markup for search form, comment form, and comments 
    * to output valid HTML5. 
    */ 
    add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption')); 
} 
endif; // aaron_setup 
add_action('after_setup_theme', 'aaron_setup'); 

因为两者都有相同的钩子。

+0

尝试在'after_setup_theme'挂钩中具有较低的优先级。 – Nilambar

+0

如果在父主题中存在正确的功能,而不是在子主题中,它应该会自动工作。很可能你的子主题中有一个*不同的*函数,它覆盖了父函数,根本不应该存在。 – rnevius

+0

@dda,感谢您编辑邮件。 –

回答

2

您需要晚于父主题运行您的挂钩。你需要记住,首先加载子主题,然后加载父主题。

为了使您的功能正常工作,您需要较低的优先级,这是一个较高的数字。您可以尝试

add_action('after_setup_theme', 'add_site_icon_support', 11); 
+0

谢谢!有用。我一直在寻找所有的互联网,只是找不到正确的答案...我读了一些关于儿童主题加载的文章,但没有关于优先事项......只有10是默认数字或类似的东西。 .. –

+0

我的荣幸,很高兴它的工作:-) –