• Resolved Fretless

    (@fretless)


    Hi guys. I’ve been working on this for a couple of days but with no luck, and I’ve searched through the forum but still haven’t found what I’m looking for. So I’ve decided to finally ask some of the extremely helpful people here for advice.

    I’ve just recently “discovered” widgets, having never bothered to use them before. I currently have a theme for my blog which is based on Kubrick, so “widgetizing” it has been pretty easy.

    The main problem I have though is that I have a customized sidebar, with images instead of text for categories, archives, meta etc. Of course when I use widgets on my theme I lose this feature in my sidebar and it just reverts back to text.

    So basically I would like to know if there is an easy way to make the Kubrick sidebar into a standalone widget? I’ve tried the various php/text widgets but they haven’t seemed to work. The css is messed up for one thing and the images don’t show. If someone can help with the sidebar widget code I would appreciate it very much. If I can get it to that stage then I should (hopefully) be able to just overlay the standard Kubrick sidebar with my custom one.

    Thanks in advance.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Its pretty easy. In your wp-content/plugins/widgets directory, create a file called sbar.php (or any other name you like), and insert the following code:

    <?php
    /*
    Plugin Name: sbarwidget
    Plugin URI: http://
    Description: Adds a sidebar widget for ...
    Author: You
    Version: 1.0
    Author URI: http://
    
    */
    function widget_sbar_init() {
    
    if ( !function_exists('register_sidebar_widget') )
    		return;
    
    	function widget_sbar() {
    
    		echo $before_widget;
    /* put your code here */
    
    		echo $after_widget;
    	}
    
    	register_sidebar_widget('Sbar', 'widget_sbar');
    } 
    
    	add_action('plugins_loaded', 'widget_sbar_init');
    ?>

    This is pretty much a basic framework for a sidebar widget.

    Thread Starter Fretless

    (@fretless)

    Thanks Zoutesnor, but I keep on getting syntax errors when I try your code. Usually with ‘<‘. Any ideas?

    Hi, I have a related question….where do I find the wp-content/plugins/widgets directory ?? I’ve read all the info on uploading plugins, but I don’t know where this directory is.

    Thread Starter Fretless

    (@fretless)

    I should add that I’d be willing to pay for a working widget if the price was reasonable. I know that it’s a quick and easy job for a skilled coder (which I’m not) to do, so I guess that should keep the cost down. I’d also pay through PayPal if anyone is interested.

    Basically I’m looking for the entire Kubrick sidebar made into a working widget. Any takers?

    Could you give me an example of a syntax error (complete error code)? Usually this happens when you’re trying to put html code inbetween php code. Try in the example above to do this:

    echo $before_widget;
    ?>
    <!-- put your code here -->
    <?php
    echo $after_widget;

    Thread Starter Fretless

    (@fretless)

    amusedcy> You create it, from memory. Just create a widgets folder inside your plugins folder.

    Thread Starter Fretless

    (@fretless)

    Zoutesnor>> No syntax errors that time, but nothing showed up in the sidebar, and my page was hellishly long and without a footer.

    Ah, I just found it. It was in Options/Miscellaneous

    To clarify: what I found in Options/Miscellaneous was:
    wp-content/uploads

    I also found this help page elsewhere in WP:
    http://codex.wordpress.org/Managing_Plugins

    My bad, you should get rid of the comment tags, the <!– and –> thingys.

    And you’re willing to pay for something which would take about 2 minutes to build and upload? Wow. Here you go (it’s on the house).

    Thread Starter Fretless

    (@fretless)

    Thanks Zoutesnor. Much appreciative of your time. The code almost works, but it outputs everything to the far right (over the background) rather than in the actual sidebar. Any ideas about that?

    I thought that it would be much better to pay someone who’s much more proficient with php than I am, rather than screwing around with it myself (and getting frustrated with the results). I’m not a programmer so I thought I’d leave it to the experts.

    Thread Starter Fretless

    (@fretless)

    By the way, glad you sorted your problem out, amusedcy.

    Thread Starter Fretless

    (@fretless)

    I think I’ve worked this out now. I removed < div id=”sidebar” > and that seemed to sort out my alignment problem. I did have bullets all over the place on the sidebar though but I removed the top and bottom < ul >< /ul > and that seemed to work. Am I likely to have any layout problems by doing this however?

    Thanks for all your help, Zoutesnor. Much appreciated!

    After I posted it, I was afraid the things you said where going to happen. But I think you’ve solved it in the right way.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Making a standalone sidebar widget’ is closed to new replies.