WordPress.org

Ready to get started?Download WordPress

Forums

Quark
[resolved] Register new widget areas (2 posts)

  1. slamjam
    Member
    Posted 8 months ago #

    Hi. I try to register new widget areas in my quark-child theme. Thats how my functions.php looks:

    <?php
    function quark-child_widgets_init() {
            register_sidebar( array(
                            'name' => esc_html__( 'startseite', 'quark-child' ),
                            'id' => 'startseite',
                            'description' => esc_html__( 'Auf der Startseite rechts', 'quark-child' ),
                            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
                            'after_widget' => '</aside>',
                            'before_title' => '<span class="schriftgross">',
                            'after_title' => '</span>'
                    ) );
    }
    add_action( 'widgets_init', 'quark-child_widgets_init' );
    ?>

    It's not working :-)

    I am a beginner in php. i checked the wordpress codex an more than one description about how do to that. No success.

    It would be great if someone could help me.

    I put the functions.php file in my quark-child folder

  2. ahortin
    Member
    Theme Author

    Posted 7 months ago #

    Remove the '-' from your function name or change it to an underscore. eg. Change it to quark_child_widgets_init()

    Don't forget to also change it in the add_action() function as well.

    "Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*."

    You can find out more about valid PHP functions here...
    http://www.php.net/manual/en/functions.user-defined.php

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.