WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add twitter code to a widget (22 posts)

  1. bidays
    Member
    Posted 2 years ago #

    Hello,

    I am trying to create a widget just to add a twitter app code so that i can remove and place it wherever i want to.
    What am i supposed to add? Here's the simple script i would like to add to a widget.

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Thanks id advance.

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Create a function to be called in the widget http://codex.wordpress.org/Widgets_API

  3. bidays
    Member
    Posted 2 years ago #

    Ok I added it but the problem is that I can't center the app
    Where is a photo :http://img688.imageshack.us/img688/113/capturedcran20120527221.png

  4. bidays
    Member
    Posted 2 years ago #

    Can someone just tell me which file i have to modify?
    i dont understand what files the widget uses to get its style. I am looking for a css file
    to change the visual of the widget. as you can see on the picture i've posted earlier:

    :http://img688.imageshack.us/img688/113/capturedcran20120527221.png

    Thanks in advance.

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    i dont understand what files the widget uses to get its style.

    From your theme's CSS. Try using Firefox with the Firebug add-on for this kind of CSS work.
    http://getfirebug.com/

  6. bidays
    Member
    Posted 2 years ago #

    Hey thanks a lot for that app. it works great.
    The only problem i have is that i only need to modify one widget, when i change the style in the style.css file it changes all widgets.

  7. bidays
    Member
    Posted 2 years ago #

    What i think i have to do is to add a style for the widgets and copy the same parameters but changing the padding. I can do that.

    What i can't find is where the widget's style is called. I guess that each widget calls the same style under style.css
    Is this a good approach?

    Could someone tell me where to change that?

    thanks in advance

  8. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    What i can't find is where the widget's style is called. I guess that each widget calls the same style under style.css
    Is this a good approach?

    Could someone tell me where to change that?

    We'd need to see the relevant Widget code, in order to answer that question. I assume you added your Widget using the Widget API ("widget-name extends class WP_Widget....")? If so, we need to see the function widget() code from inside the class.

  9. bidays
    Member
    Posted 2 years ago #

    well using the plug in firebird
    i select the widget after the title and this is what i get:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    is that what you mean?

  10. bidays
    Member
    Posted 2 years ago #

    Oh sorry for that,

    here is the link paste bin for the code:

    http://pastebin.com/61VtZeFM

  11. esmi
    Forum Moderator
    Posted 2 years ago #

    Can we have a link a page showing this widget please?

  12. bidays
    Member
    Posted 2 years ago #

    Yes you can visit the homepage as its on the sidebar:

    http://www.naimedart.com

  13. esmi
    Forum Moderator
    Posted 2 years ago #

    It's the default padding on your sidebar widgets that is causing the problem but, in order to target any new CSS at that specific widget, you'd need to add a new class to that custom(?) widget.

  14. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    It's the default padding on your sidebar widgets that is causing the problem but, in order to target any new CSS at that specific widget, you'd need to add a new class to that custom(?) widget.

    ...which, really, is what I was getting at above, by asking for the function widget() code. But, based on the Pastebin, I wonder if the OP isn't actually using the Widgets API to create this Widget?

  15. esmi
    Forum Moderator
    Posted 2 years ago #

    That doesn't look like it to me. But then I also noticed that the other widgets all use the same class. Perhaps the theme's functions.php also needs to be modified to output a unique class or id for each widget as recommended by the Codex? It sure makes like easier long term.

  16. bidays
    Member
    Posted 2 years ago #

    So what do you guys recommend me to do? i don't really understand sorry.
    but thanks for you help though.

  17. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    So what do you guys recommend me to do? i don't really understand sorry.

    I wrote a Twitter Widget, that might be instructive. Have a look at the code, and see if it helps. It is written using the Widgets API, which is the proper framework to use when developing custom Widgets.

  18. bidays
    Member
    Posted 2 years ago #

    Thats a cool widget thanks..
    but i can't believe it still does the same thing: http://www.naimedart.com
    its not centered

  19. bidays
    Member
    Posted 2 years ago #

    I checked in functions.php in the themes folder and i didn't really find anything usefulL.
    i forgot to precise that before getting this problem i changed the themes size.
    i added size to the left area ( content ) and removed some from the sidebar to make it smaller.
    Maybe i should of have changed something while doing this?

  20. bidays
    Member
    Posted 2 years ago #

    Nevermind thanks, luckily i could change the padding of the general widgets style under style.css and it doesn't look so bad.
    although i would like to ask a question, how can i apply a independent style to a specific widget.

  21. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    although i would like to ask a question, how can i apply a independent style to a specific widget.

    That's actually why I directed you toward my Plugin. :)

    If you look at this bit:

    function widget_cbnet_twitter_widget() {
            $widget_ops = array('classname' => 'widget-cbnet-twitter-widget', 'description' => 'Widget to display Twitter widgets' );
            $this->WP_Widget('plugin_cbnet_twitter_widget', 'cbnet Twitter Widget', $widget_ops);
        }

    You can see that WordPress will output a .widget-cbnet-twitter-widget class that you can target for CSS styles specific to this Widget.

  22. bidays
    Member
    Posted 2 years ago #

    Thanks i can now consider it as resolved. Thanks for your help

Topic Closed

This topic has been closed to new replies.

About this Topic