Desizn Tech logo
  • Home
  • Freebies
  • Showcase
  • Tutorial
  • Photography

WordPress and jQuery: Troubleshooting, Implementing Sidebar Tabs and More

By Kawsar Ali, 19 February, 2010 & filed under Tutorial, Wordpress

WordPress and jQuery can work effectively if implemented correctly. It can enhance your blogs functionality and usability. In this post we will look at some wordpress-jQuery troubleshooting tips, techniques and also how to add tabs to your sidebar.

Troubleshooting jQuery

Let’s start from the top. I did not realize many people also had the same problem until I googled about it. Is jQuery not working with your wordpress theme? There could be several reasons. First, make sure your calling your jQuery the right way, as Jeff Star point out here, which is :

[php]
<?php wp_enqueue_script("jquery"); ?>
[/php]


Put this code right before your wp_head. What this code is, it is calling for the jQuery that is included in your wp-includes folder. The benefit of calling jQuery like this, you do not have to update jQuery every time and you are not calling same file twice. What if your jQuery is not still working? My jQuery was not still working either. I put a test function to check it, the test function work but other scripts were not working . After googling for a while I found out , after updating to wordpress version 2.9, you have to call jQuery in a different way.  You have to replace every “$” with jQuery . Here is an example:

This seemed to fix my jQuery problem. All my scripts were working after this. I faced this problem after updating to worpdress 2.9. Before that all the scripts were working. Regardless you should call wordpress with wp_enqueue_script. Also, to make your site faster,  here is an old tip. Include all your scripts right before the wp_footer, because if you include them in the header they must load before the body and sidebar can load.

WordPress 2.9 features

There has been already so many post about wordpress 2.9 features  such as global undo,  included image editor and more. One feature I would like to mention is the_post_image() features. Before we would usually add thumbnails for the post with custom fields hacks. As WordPress Enginner mentions,  now we can add the support for thumbnail in our theme by adding this:

[php]
<?php the_post_image(‘medium’);?>
the_post_image(); // without parameter -> Thumbnail
the_post_image(‘thumbnail’); // Thumbnail
the_post_image(‘medium’); // Medium resolution
[/php]

When you upload any image and you want to set it as thumbnail you should see an option to set it as thumbnail . What if you want a custom size , you can do it so by following

[php]
<?php the_post_thumbnail(array( 200,200 ), array( ‘class’ => ‘alignleft’ ));?>
[/php]

If you want to more customization head over to Webbbzone’s and  Kremalicious post for details.

Adding Sidebar Tabs


I mentioned in a previous post how you can add sidebar tabs to your wordpress theme. Up until recently, here at Desizn Tech I was using sidebarTabs . As far as I know, that is only the plugin for tabbed sidebar and there is some tabbed widgets. The problem with that plugin and other Tabbed widgets sometimes plugin do not play nice with each other and some of them do not work. Moreover, you cannot add anything custom. I was looking around the web to see if there already something pre-made for wordpress already. However, I could not find one. That is why I decided to make something that works with wordpress . The original script is from a Nettuts tutorial by Dan Harper. I am just porting it to wordpress. This script uses jQuery UI Tabs. The current effect is ‘”toggle”, you can change it to whatever you prefer. If you want to add this to your website, you would just have to upload the files to your wordpress theme folder. Makes sure jQuery is called and add the following  files in your header:

[php]
<link rel="stylesheet" type="text/css" href="<?php bloginfo(‘template_url’); ?>/sidebar_style.css"/>
<script type="text/javascript" src="<?php bloginfo(‘template_url’); ?>/js/jquery-ui-personalized-1.5.2.packed.js"></script>
<script type="text/javascript" src="<?php bloginfo(‘template_url’); ?>/js/sidebar_tab.js"></script>
[/php]

An then just include this in your theme sidebar :

[php]
<?php include (‘sidebar_tabs.php’) ?>
[/php]

By default it shows your 5 popular posts, categories, tags. You can also change that to what you want to show. For example:

List pages:
<?php wp_list_pages('title_li='); ?>
Display Archive By Month:
<?php wp_get_archives('type=monthly&limit=12'); ?>


You can also call a plugin to show whatever you want it to show. If you want to style it differently reference to tabs_style.css and style to however you want. You can see a preview of the sidebar working on Desizn Tech’s sidebar.

[download#18#nohits]

If you find any bugs or have suggestions please add it in the comments

Pin It
Tweet

Author: Kawsar Ali

Kawsar Ali is a web designer who also likes blogging. He is the curator of Desizn Tech. In his spare time he walks around with a Nikon D5100 hunting for good textures.



Related posts:
  • Remove WordPress Meta
  • Playing with jQuery Color Plugin and Color Animation
  • 15 Website for jQuery Enthusiast and Addicts
  • WordPress Hacks and Tweaks to Visually Empower Your Website
  • 15 Handpicked Fresh and Useful jQuery Tutorials


25 Responses

  1. PHILIP January 15, 2012

    YOUR A GENIUS THANKS SO MUCH, 3HOURS OF SEARCHING

  2. James | Automatic Photo Scanner November 23, 2011

    I hope this will still work with the latest WP platform. I really am in a bind as the plugins doesn’t seem to work on my theme.

  3. Mahesh Rao June 21, 2011

    I am going to implement the tabs in a Thesis theme. thanks for the handy note.

  4. Nina June 17, 2011

    Hello,

    Do your sidebar tabs also work with WordPress 3.1.3. ?
    I downloaded it.
    Then I did: Plugins –> Add new –> Upload –> Selected the file –> activate plugin
    Afther that I get the folowing Error: The plugin does not have a valid header.

    When I return to the plugin page, I can’t see your plugin.
    What am I doing wrong?

    Thank you,
    Nina

  5. vibe web design February 11, 2011

    Great post. Thank you! We found it very usefull

  6. Adhi October 9, 2010

    Nice useful article keep posting like this.. Thanks for sharing this info.
    My Blog

  7. IT Solutions September 27, 2010

    Thanks this is very helpful and has resolved my problem

  8. technology July 12, 2010

    Thanks the author for article. This is a great post.

  9. @KarmaTiger July 4, 2010

    Everything works great except the CSS. Even correcting the sidebar_style.css to tab_style.css, the styling works for the tabs themselves but all 3 kinds of information are shown in a conventional, top to bottom linear UL list.

    I can’t for the life of me get it to recognisz the .tabdiv class

    • Nathan July 6, 2010

      Did you get this sorted out? Curious for my own site.

      • Kawsar Ali July 6, 2010

        I have updated the file name, Now it should work. Sorry for the trouble.

    • Kawsar Ali July 6, 2010

      Did you uploaded in the same directory? Make sure it is on the same directory and you can also try hard liking in to test it

      • Nathan July 16, 2010

        I’m having trouble getting -any- jquery tabs to work. When I couldn’t get yours to work, I tried some others, but I keep having the same problem, so I think I’m doing something very basic wrong (which is definitely possible since I’m new to all this). The tabs themselves are there and styled, but nothing gets hidden. Instead, everything gets listed below the tabs.

        I still have yours up on my sidebar, so if you get a chance, could you (or anyone who knows what they’re doing, really) take a look and see if you can tell what I’m missing?

        I’d very much appreciate it.

  10. Nathan June 30, 2010

    Don’t know if this has been pointed out yet, but the example you give for the header uses sidebar_style.css, but the file in the download is actually tabs_style.css. I couldn’t figure out what I was doing wrong until I saw that. Some things still aren’t quite right on mine, but at least now I know why nothing was styled.

    • Kawsar Ali July 6, 2010

      Fixed, Thanks for pointing out

  11. ZAREMA March 19, 2010

    Thanks the author for article. The main thing do not forget about users, and continue in the same spirit.

  12. sadri March 15, 2010

    I like this tabs thanks

  13. WP Themes March 13, 2010

    Nice brief and this enter helped me alot in my college assignement. Say thank you you as your information.

  14. Joe February 23, 2010

    Really useful post. Ive never really got wordpress and jquery to get along. Ill be using this on my next project!

  15. Hermitbiker February 22, 2010

    …. excellent tutorials and trouble-shooting for jQuery and WordPress, thanks “Desizntech” !!

  16. JC February 22, 2010

    These are great. I have just really started with JQuery and this will help a lot. Thanks and keep it up!

  17. Stephen Cronin February 21, 2010

    Just a note: you don’t have to replace all the $ with jQuery if you use them inside a function called in the following way:

    jQuery(document).ready(function($) {

    });

    Note the $ as a parameter of the function.

    You have to use jQuery instead of $ once in calling that function, but then the $ will work inside that.
    .-= Stephen Cronin´s last blog : The Solution To The Lack Of WordPress Beta Testing =-.

  18. Boston Web Design February 21, 2010

    This is a great post. I’ve always had a bit of trouble implementing jQuery with wordpress. Its good to see this practical examples. I will indeed build off these concepts.

    Cheers!!

  19. Bariski | TutZone.net February 21, 2010

    This surely will come in handy.
    .-= Bariski | TutZone.net´s last blog : Winners Of 5 Pro Licenses from Oops!Backup =-.

  20. sriganesh February 20, 2010

    thanks for sharing this tutorial, ill try to apply, i always like tab option and it reduce the space in the sidebar.

Stay Connected

rss twitter facebook google

Search


Cheap Tablet PC

Our Supporters

  • Cloud Storage
  • Dedicated Server
  • Modern Furniture
  • Online Business Printing
  • Online Backup
  • Logo Design
  • Wow Gold
  • Secure and protect your business with SiteLock.
  • Festklänningar
  • Blogroll

    AnimHut
    Designmodo – Web Design
    Design Superhero
    Inspireyourway
    iBrandStudio
    OurTuts
    Skyje
    Stock Images
    Vector Pack
    365icon
    TexTuts

    • About
    • Contact
    • Contribute
    • Privacy Policy

    Copyright © 2008-2013 Desizn Tech