Options

Any wordpress/PHP gurus here ?

DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
Hi,

I been looking for a way to add widgets in wordpress 3.0.1 to the top menu bar.

I have been pointed in the direction of a few web sites but I am a complete novice to PHP.

What I want it to be able to display link categories in the top menu rather than the side menu, and I am sure it can be done but I would really like some help in setting it up.

So if any one knows what I am on about please help :)

Aaron
  • If you can't explain it simply, you don't understand it well enough. Albert Einstein
  • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.

Comments

  • Options
    Forsaken_GAForsaken_GA Member Posts: 4,024
    You can't do it without modifying either the code, or the theme in stock Wordpress. The easiest way to do it is to find a theme that already does what you want, then it's just a matter of simple modifications. Otherwise you get to learn PHP!
  • Options
    pml1pml1 Member Posts: 147
    Yeah, you'll definitely have to edit the PHP, but it's not too complicated. I've only ever placed widgets in a sidebar, but you can put them anywhere you want.

    You'll need to add this in the div that contains your top bar:

    [PHP]<?php if (!function_exists('dynamic_sidebar') ||
    !dynamic_sidebar('Top Widgets')) : ?>

    <!-- CONTENT HERE WILL ONLY DISPLAY IF NO WIDGETS ARE ACTIVE -->

    <? end if; ?>[/PHP]

    Then, in your functions.php add something like this:

    [PHP]if (function_exists('register_sidebar')) {
    register_sidebar(array(
    'name' => 'Top Widgets',
    'before_widget' => '<div id="%1$s" class="%2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettittle">',
    'after_title' => '</h4>',
    ));
    }[/PHP]

    That's just a quick thought. It may not work exactly like there...and there may be typos icon_wink.gif If it does work, it will add a new area named "Top Widgets" in your widgets section.
    Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution and the vision to see obstacles as opportunities.
  • Options
    pml1pml1 Member Posts: 147
    Another thing that may trip you up is that most widgets are designed to be placed in a vertical orientation (ie sidebar). I'm assuming you'll want them horizontal if they're going to be in your top bar. You may have to edit some CSS to make that come out like you want. You may want to to wrap the the <?php if [...] end if; ?> with a <ul> and then change the before_widget and after_widget values to <li> elements. You can then display those inline. That would be easier than trying to float <divs> all over the place.
    Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution and the vision to see obstacles as opportunities.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    cheers guys,

    in the end I found a nice plugin to convert links to pages as you can see in the tips and tricks page.

    WordPress › WP Render Blogroll Links WordPress Plugins

    bit like Colby suggested. (i liked this one a bit better as it had more granularity about it)

    I had a look at the PHP but I think I will come back to that later, got a SWITCH exam to revise for at the moment :)

    once again cheers for all the help
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Options
    pml1pml1 Member Posts: 147
    Hey, I'm glad you found a solution. I think I misread your original question anyway. My method was way overkill for what you're wanting.
    Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution and the vision to see obstacles as opportunities.
  • Options
    DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    pml1 wrote: »
    Hey, I'm glad you found a solution. I think I misread your original question anyway. My method was way overkill for what you're wanting.

    Hi, :)

    Actually I looked at a solution simmler to yours, and I do want to get it sorted like that at some point. As it will look much better, but I think I still a little two green with PHP at the moment :)
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
Sign In or Register to comment.