Johnny
Johnny

Reputation: 576

WordPress - How To Allow Header And Footer Sections To Be Edited

I was just wondering what approach people take when it comes to making the header and footer sections editable within WordPress?

For most sites these areas are static and the client does not want or need to amend them.

I do have the awesome Advanced Custom Fields plugin installed and am not sure if that can be utilised?

All suggestions are greatly appreciated.

Upvotes: 2

Views: 4547

Answers (1)

Howli
Howli

Reputation: 12469

You could add two widgets, one to the header and one to the footer. This can be done by adding the following to the functions.php file:

register_sidebar( array(
    'name' => __( 'Header information', 'twentytwelve' ),
    'id' => 'header-information',
    'description' => __( 'Information for the header', 'twentytwelve' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

register_sidebar( array(
    'name' => __( 'Footer information', 'twentytwelve' ),
    'id' => 'footer-information',
    'description' => __( 'Information for the footer', 'twentytwelve' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

Then add

dynamic_sidebar( 'header-information' );

to the header.php file and

dynamic_sidebar( 'footer-information' );

to the footer.php file

Then in the widgets section on the backend you can add widgets to the header and footer sections. With that you can add/remove images/text etc from the header/footer.

Upvotes: 4

Related Questions