WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how does the footer.php get the footer widget information from functions.php? (6 posts)

  1. sabster
    Member
    Posted 2 years ago #

    hey everyone. i'm using twentyten and i'm making a child theme and i'm trying to figure out logically HOW the registered widget areas in functions.php are put into the footer.php area?

    here's the code (i think) for the widget's in the footer in functions.php:

    // Area 3, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'First Footer Widget Area', 'twentyten' ),
    		'id' => 'first-footer-widget-area',
    		'description' => __( 'The first footer widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );
    
    	// Area 4, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Second Footer Widget Area', 'twentyten' ),
    		'id' => 'second-footer-widget-area',
    		'description' => __( 'The second footer widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );
    
    	// Area 5, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Third Footer Widget Area', 'twentyten' ),
    		'id' => 'third-footer-widget-area',
    		'description' => __( 'The third footer widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );
    
    	// Area 6, located in the footer. Empty by default.
    	register_sidebar( array(
    		'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
    		'id' => 'fourth-footer-widget-area',
    		'description' => __( 'The fourth footer widget area', 'twentyten' ),
    		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );

    and then in the footer.php, i think this is what calls of that?

    <?php
    	/* A sidebar in the footer? Yep. You can can customize
    	 * your footer with four columns of widgets.
    	 */
    	get_sidebar( 'footer' );
    ?>

    so where does it say in the above code that there is a sidebar called footer?

    here's the CSS for it also which is kinda confusing if anyone could touch on whati s happening here....

    #footer-widget-area {
    	overflow: hidden;
    }
    #footer-widget-area .widget-area {
    	float: left;
    	margin-right: 20px;
    	width: 220px;
    }
    #footer-widget-area #fourth {
    	margin-right: 0;
    }
    #site-info {
    	float: left;
    	font-size: 14px;
    	font-weight: bold;
    	width: 700px;
    }
    #site-generator {
    	float: right;
    	width: 220px;
    }

    basically, i'm asking all these questions because i want the footer to be just ONE widget stretched across the bottom of the page and i need to do it in a child theme so i'm trying to understand what is happening here.

    also, i want to create 3 new widget areas at the top of my page to put some information inside as well... so i need to understand how the heck these things work.

  2. potentweb
    Member
    Posted 2 years ago #

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("PUT YOUR ID HERE") ) : ?>
    <?php endif; ?>

    The above is how you call the widgetized area on your theme. So if you want it in your footer, then you call it in your footer.php etc etc

  3. alchymyth
    Forum Moderator
    Posted 2 years ago #

    to get an idea of the process of building a dynamic sidebar, read http://codex.wordpress.org/Widgetizing_Themes

    get_sidebar( 'footer' ); calls the template called sidebar-footer.php

    http://codex.wordpress.org/Function_Reference/get_sidebar

    to remove some widget areas from the child theme, you can possibly work with http://codex.wordpress.org/Function_Reference/unregister_sidebar

  4. sabster
    Member
    Posted 2 years ago #

    @potentweb the thing is, in my footer.php, it is calling the get_sidebar ('footer') so i am not fully immersed in wordpress to understand what your tag does exactly.... i want to learn more though about what you are saying.

    @alcymyth thank you very much for telling me about the sidebar-footer.php. that ws the missing link here... i was like, how the hell is it getting the information to do this lol. i was able to remove the other 3 widgets and extended the one widget across the whole bottom to get the exact look and feel i want, it looks great. now round 2 i will try to make my own 3 widgets at the top lol.... but i will make another post for that if i run into trouble.

  5. potentweb
    Member
    Posted 2 years ago #

    You add the code I gave you in the template file that you want it to show up in. It calls the function you created in functions.php, so using your example, open up the sidebar file and add the code I gave you.

  6. alchymyth
    Forum Moderator
    Posted 2 years ago #

    to make my own 3 widgets at the top

    related (don't read if you like to figure this out yourself):
    http://wordpress.org/support/topic/create-3-horizontal-boxes-between-menu-and-container?replies=16

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags