Results 1 to 1 of 1

Thread: Widgetizing wordpress theme

  1. #1
    Hellas's Avatar
    Hellas is offline Very Unusual Member
    Join Date
    Dec 2008
    Location
    Bosnia
    Posts
    1,051
    Thanks
    214
    Thanked 292 Times in 205 Posts

    Widgetizing wordpress theme

    Quote Originally Posted by Shenron View Post
    And how's that? What needs to be done?

    I confess I've never tried to widgetize some of my themes. (lazy me )
    Check for start this
    Widgetizing Themes � WordPress Codex


    And here is practical example from www.easycookingguide.com (dont comment site I have lot of work to do on it) which use some theme that dont have widgetized sidebar.

    If you have sidebar.php like this:

    Code:
    <div class="nav">
    <h3>Navigation</h3>
    <ul>
    <li<?php if (is_home()) echo " class=\"selected\""; ?>><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <?php wp_list_pages('title_li=' ); ?>		
    </ul>
    </div>
    <br />
    
    <div class="nav">
    <h3>Categories</h3>
    <ul>
    <?php wp_list_cats('optioncount=0'); ?>
    </ul>
    </div>
    then you should widgetize it by adding this to sidebar.php

    Code:
    <div id="letsayanything">
    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar() ) : ?>
    /*code that will be shown if there is no widgets assigned*/
    <div class="nav">
    <h3>Navigation</h3>
    <ul>
    <li<?php if (is_home()) echo " class=\"selected\""; ?>><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <?php wp_list_pages('title_li=' ); ?>		
    </ul>
    </div>
    <br />
    
    <div class="nav">
    <h3>Categories</h3>
    <ul>
    <?php wp_list_cats('optioncount=0'); ?>
    </ul>
    </div>
    
    <?php endif; ?>
    </div>
    then create function.php and insert this
    Code:
    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar();
    ?>
    however in this case Wordpress will insert its default formatting <h2> tags which is not as in our example
    so we will add some parameters to our functions.php which whill change code to look like as in our example code
    so functions.php will look something like this

    Code:
    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '<div class="nav">',
            'after_widget' => '</div></br>',
            'before_title' => '<h3>',
            'after_title' => '</h3>',
        ));
    ?>
    That is it.

    Our sidebar is now widgetized even if I did not wanted to widgetize it .

    Feel free to correct me since I am not expert in this field .

  2. Thanked by:

    Shenron (18 August, 2009)

Similar Threads

  1. Replies: 0
    Last Post: 2 May, 2011, 08:10 AM
  2. [Free] Free Premium WordPress Theme (Market Theme)
    By badmash in forum Themes
    Replies: 0
    Last Post: 22 November, 2009, 03:04 AM
  3. Replies: 0
    Last Post: 26 June, 2009, 08:38 AM
  4. Replies: 0
    Last Post: 24 February, 2009, 07:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •