• Just a question… I have been looking at several templates like the BONES… and _underscore etc. and everyone has a different method of setting up a function file..

    The bones one really confuses me as it removes a whole bunch of stuff and adds things

    is there a specific way to actually setup a proper functions file?

    Right now I have a function file with things just added in there like this

    <?php
    // Register Sidebar
    function  my_custom_sides()  {
    	register_sidebar ( array(
    		'id'            => 'top-sidebar',
    		'name'          => __( 'Top Side' ),
    		'description' => __( 'Appears when using the optional Front Page template with a page set as Static Front Page', 'twentytwelve' ),
    		'before_title'  => '<h2 class="widgettitle">',
    		'after_title'   => '</h2>',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</li>',
    	));
    
    }
    
    add_action( 'widgets_init', 'my_custom_sides' );
    ?>

    but I have read that a proper format is adding this?

    if ( ! function_exists( '_optz_setup' ) ) :
    
    function _optz_setup() {
    	load_theme_textdomain( '_optz', get_template_directory() . '/languages' );
    
    	add_theme_support( 'automatic-feed-links' );
    	register_nav_menus( array(
    		'primary' => __( 'Primary Menu', '_optz' ),
    	) );
    
    	add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
    }
    endif; // _optz_setup
    add_action( 'after_setup_theme', '_optz_setup' );

    Is it necessary to add the setup and after_setup_theme code? can’t i just put in a few things I want the theme to do and call it a day 😀

    or do i have to put all my side bars etc in between there?

Viewing 1 replies (of 1 total)
  • is there a specific way to actually setup a proper functions file?

    Not as such. It depends upon what your theme needs. But there are definitely best practice recommendations that you could use as a starting point – especially if you are thinking of removing core functionality. The general rule of thumb is “don’t”.

    I have read that a proper format is adding this?

    The second code example is doing something very different from the first and, as such, both are correct.

    Is it necessary to add the setup and after_setup_theme code?

    Not for everything, no. Again, it depends what you’re doing.

Viewing 1 replies (of 1 total)

The topic ‘Proper Functions.php Setup….?’ is closed to new replies.