Hey I’m kinda new to php and wordpress development and I’m just experimenting with how wordpress works and how the themes work. Now I have tried looking this up many times but no help. It was always something different and things that worked for those people, didnt work for me. here is the code,
<?php
function sandor_hero_cap() {
$wp_customize->add_section('sandor_subhead_title', array(
'title' => __('Sub-Header', 'sandor'),
));
$wp_customize->add_setting('sandor_subhead_title', array(
'default' => 'A Virtual PLAYGROUND',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_text_field'
));
$wp_customize->add_control('sandor_subhead_title', array(
'label' => __('Sub-Header Title', 'sandor'),
'section' => 'sandor_subhead_section',
'priority' => 5,
'settings' => 'sandor_subhead_title'
));
}
add_action( 'customize_register', 'sandor_hero_cap' );
?>
the error that im getting is:
Call to a member function add_section() on a non-object in functions.php line 5
I have tried a lot of things but nothing seems to be working, hopefully you guys can help me solve this issue. thanks 🙂
You’re missing the
$wp_customize
argument. And, if I’m not mistaken, it might be an idea to use a different name foradd_setting
andadd_control
. See the code below.