How to widgetise Grid Focus wordpress theme
Jun
05
2007

It seems that after much debate and a multitude of emails, Derek Punsalan decided to release his Grid Focus Wordpress theme to the general public. I, for one am grateful for this as the Grid Focus theme has now become the base theme for my new site design. It’s work in progress and I still have a few things I want to try out before I can call it complete.

One of the things I wanted to add to this theme, was support for widgets. Grid Focs is a 3 column theme. Out of the box, the two right most columns contain hard coded elements. But what if you wanted to change the content of those two columns regularly with no fuss? Widget support is the ticket.
So, inline with Derek’s philosophy here is my contribution to the theme: I bring you, how to widgetise the Grid Focus wordpress theme. In this tutorial I will show you how you can add widget support to the columns shown in red in the picture below.

Widget Grid Focus

It’s very simple and you can probably do it in 5 minutes. Remember before you start, to backup all the files you will require to modify - I will not be held responsible if it does work. This has been tested on my web site running wordpress version 2.2.

Ok, let’s get started.

Step 1:

The first thing you need to do is to create a file called ‘functions.php’ in which you have add the following code. This is a file that Wordpress looks for and reads it if it finds it:


<?php
if ( function_exists('register_sidebar') )
    register_sidebars((2),array(
        'before_widget' => '<div class="sidebar_widget">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
    ));
?>

Once you have done that, save your file and upload it in the same folder that holds your theme.

Step 2:

In this step you will need to modify the file originally provided with the theme called ’second.php’. This step really is up to you as it depends on much of the original structure you want to keep. For example you might want to keep the link sections and add widgets, you might want to keep the meta section and add widgets - it’s up to you. In my case, I have kept the search form and added widget capability.

The original code of the file ’second.php’ was:


<div id="midCol">
	<?php incmVFRDTDUDr6V&6f&rРFb673&֖FFUƖ2#Рƃ3W"66RƖ33РW"66RƖ2WB&VFW'2rvBFW6VB&R&VFrW"6FRРVРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРVРFcРFb673&֖FFUƖ2#Рƃ3W"66RƖ33РW"66RƖ2WB&VFW'2rvBFW6VB&R&VFrW"6FRРVРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРƓ&Vc"2#ƖFFSƖFW67&FF“ƓРVРFcРFb673&֖FFUƖ2#Рƃ37V'67&&S3Р7FWFFVBגVFW&rFVvG2f7FfFW2f%527F6FRРVРƓ&Vc&fVVC&vfw'73%W&r"FFS$gV6FVB%52fVVB#6FVB%537G&vBFW"&VFW#ƓРƓ&Vc&fVVC&vfv6VG5'73%W&r"FFS$gV6VG2%52fVVB#6VG2%53FBFFRF67W76ƓРVРFcРFb673&֖FFUƖ2#Рƃ3WF3РVРw&Vv7FW"РƓwvWBƓРwWFРVРFcУFcР

After my changes, my file now looks like:


<div id="midCol">
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
<?php endif; ?>
</div>

Step 3:

In this step you will need to modify the file originally provided with the theme called ‘third.php’. Again, this depends on you - on how much of the original file you want to keep. In my case, I have kept the original file structure (i.e the option to add picture links) and simply added widget capability before the links.

The original code of the file ‘third.php’ was:


<div id="tertCol">
	<div id="elseWhere">
		<h3>Before you go</h3>
		<p>Going so soon? May these links be a guide to web enlightenment. Schwing!</p>
		<ul id="imgLinks">
			<li><a href="http://5thirtyone.com/grid-focus" title="Download Grid Focus by: Derek Punsalan"><img src="<?php bloginfo('template_directory'); ?>/images/guide/grid_focus_531.gif" alt="Grid Focus - 531" /></a></li>
			<li><a href="http://is.derekpunsalan.com/" title="Visit Derek Punsalan...is"><img src="<?php bloginfo('template_directory'); ?>/images/guide/is.gif" alt="Derek Punsalan...is" /></a></li>
		</ul>
	</div><!-- close #imgLinks -->
</div><!-- close #tertCol -->

After my changes, my file now looks like:


<div id="tertCol">
	<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>
	<?php endif; ?>
	<div id="elseWhere">
		<h3>Before you go</h3>
		<p>Going so soon? May these links be a guide to web enlightenment. Schwing!</p>
		<ul id="imgLinks">
			<li><a href="http://5thirtyone.com/grid-focus" title="Download Grid Focus by: Derek Punsalan"><img src="<?php bloginfo('template_directory'); ?>/images/guide/grid_focus_531.gif" alt="Grid Focus - 531" /></a></li>
			<li><a href="http://is.derekpunsalan.com/" title="Visit Derek Punsalan...is"><img src="<?php bloginfo('template_directory'); ?>/images/guide/is.gif" alt="Derek Punsalan...is" /></a></li>
		</ul>
	</div><!-- close #imgLinks -->
</div><!-- close #tertCol -->

All you now have to do, is to go to the ‘Widgets’ section (under Presentation) in the admin part of your site and add the widgets you want.

I have included has a ‘help’ an archive file that contains all three created/modified files. You can grab that archive file by clicking on the shopping cart below.

shopping cart

74 Responses to “How to widgetise Grid Focus wordpress theme”

  1. Gravatar of Parm Parm

    Ooooh I could kiss you right now! Fabulous, I’m gonna go give that a try! :)

  2. Gravatar of Parm Parm

    I can confirm that it definately works, very easy to setup. The standard WP widgets however look really ugly! >_

  3. Gravatar of Pascal Pascal

    Glad to hear this was helpful.
    You can always tweak the css of the widgets to your liking!

  4. Gravatar of Jessie Jessie

    Yes thank you! Thank you for this tutorial. Very simple and clear.

  5. Gravatar of Pascal Pascal

    Not a problem…Glad you found it useful.

  6. Gravatar of Jessie Jessie

    Just a question. How do I get Grid Focus to display the pages of my blog like you did at the top navigational bar?

  7. Gravatar of Pascal Pascal

    Not sure I understand your question Jessie.
    Do you want to know how to customise the navigation bar? If not can you be more specific?

  8. Gravatar of Jessie Jessie

    Ah, sorry for being unclear. Yes I was talking about how to customize the navigation bar because I thought that the theme would automatically display my pages, but I guess not. Thanks in advance!

  9. Gravatar of Pascal Pascal

    The links in the navigtion bar are hard coded. I you want to edit those you have to edit the file called header.php
    Look for the tag <ul class="nav fix">.
    The lines immeadiatly after it represent the links that appear in the navigtion bar. Hope it helps.

  10. Gravatar of Steve Tucker Steve Tucker

    Good design, Pascal - you’ve really put a good spin on the theme :) Only (constructive) criticism is that you’ve got a little bit of horizontal scrolling, despite that I really like it!

  11. Gravatar of Pascal Pascal

    Thanks Steve, but this is only temporary. I’m working on a new theme at the moment.
    What do you mean horizontal scrolling? How many pixels can you display on your Macs?

  12. Gravatar of Steve Tucker Steve Tucker

    Ah no. Im on a PC at the moment (at work) and its displaying in 1024×768. Looks to be about 50px horizontal scrolling.

  13. Gravatar of Jared Jared

    I’m trying to implement this on my site, but the WP admin is still alerting me to the fact that: “You are seeing this message because the theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please follow these instructions.”

    Any thoughts on why I’d be seeing this? I am using grid_focus on WP 2.2

  14. Gravatar of Pascal Pascal

    Jared, it’s always difficult to help someone when one person says he should be seeing black and the other person says he is seeing white. Did you change the 2 files mentioned and add the 3rd one?

  15. Gravatar of links for 2007-06-13 « Tyrants & Tax Collectors links for 2007-06-13 « Tyrants & Tax Collectors

    [...] How to widgetise Grid Focus wordpress theme at renet@web (tags: hacks widgets wordpress themes) [...]

  16. Gravatar of robyn robyn

    Thanks for the widget information! This is spectacular and the instructions seem to be understandable. Someone was asking about the nav function–If I want my pages to be displayed in a nav above the blog info, where might I find that code? I appreciate your help!

  17. Gravatar of Pascal Pascal

    Hey Robin,
    Not sure I get you. Where do you want to add the pages? Do you want to add them in he navigation bar? Let me know ad I’ll tell you what to do. (maybe you can just put a text like ‘navigation pages here’ in your blog so I can see exactly where you want to put them).
    Cheers

  18. Gravatar of robyn robyn

    i thought of moving my nav bar from where they are now to the top of the page, similar to yours. though, now that i’m thinking about it, i’m considering leaving the nav bar where it is and inserting a header image, though not as big as yours!

    my other question is that it appears that all of my text is now “centered” and i don’t know why. AND, does it require a widget to show the feature or latest post? or, is there a way to allow more the post to be seen instead of always having to click on the title of the post?

  19. Gravatar of Pascal Pascal

    Hey Robin,
    I’ve shot you an email with my answers.
    Hope it helps.

  20. Gravatar of chris chris

    ER…..

    dear sir, i don’t know about the WP to much,could u tell me when i finish what u said,what should i do ? i go to the ‘Widgets’ section (under Presentation) in the admin part of my site and how could i add the widgets ?

    thank u

    my email

    xl.sensebb@gmail.com

  21. Gravatar of Pascal Pascal

    Yes that is correct, then just click and drag the widgets you want to the sidebar where you want them displayed. Save your settings and that should do the trick.

  22. Gravatar of chris chris

    Yeah,but i didn’t find the ‘Widgets’ section….

  23. Gravatar of Pascal Pascal

    If the under the “Presentation” menu, you do not see the sub menus “Themes” “Theme Editor” and “Sidebar Widgets”, it means that what you did is not correct - Wordpress does not recognise your theme as Widget Ready.

  24. Gravatar of chris chris

    The wp what i’am using is 2.2 , i see the sub menus “Themes” “Theme Editor” but not the“Sidebar Widgets”,i don’t know why :(

  25. Gravatar of chris chris

    my website is http://www.feixiaomi.cn and i used the three files from ur site,i don’t know why there is “Sidebar Widgets”. Could u help me to check it ? THANK YOU !

  26. Gravatar of Pascal Pascal

    It’s not going to work. My post deals with the customising of the grid focus theme. On your blog I see that you are using the old default wordpress theme. Sorry, but my post and the files I have made available for download will not work on your site.

  27. Gravatar of chris chris

    I’m sorry sir. i just deleted the the grid focus theme on my ftp and put it again for trying again. I see ur emai.THANKS A LOT and sorry for my poor english. :(

  28. Gravatar of chris chris

    Dear sir

    i have done with this problem,it’s wrong with my wp2.2.haha,THANK YOU VERY MUCK

  29. Gravatar of MerovingiaN MerovingiaN

    Hey guys,
    i’d applied all those codes to the right files, then i uploaded.
    but still i can see that message under the “Widgets” section

    “No Sidebars Defined”

    I use wordpress 2.2
    how can i solve this problem guys ?
    tack!

  30. Gravatar of Ed Cooper Ed Cooper

    My widgets are working but everytime u post a new news item or page etc it will disable all the widgets, so you have to reassign them to each sidebar. It’s quite annoying and no one can give us any help to why it’s doing it. Has anyone else had this problem?

  31. Gravatar of Pascal Pascal

    Hey Ed,
    Bummer. It’s not happening on my test server and I’ve never heard of this.
    It’s time consuming but you can try to de-activate all your widgets, then activate them one by one, write a post and see what happens - maybe one of the widgets is an issue. Do the same with plugins.
    Keep us posted.

  32. Gravatar of Sascha Sascha

    You’re a liar! I took me even less than 5 minutes ;-)) Thank you very much!

    cu
    Sascha

  33. Gravatar of Pascal Pascal

    Ah, but I see that you have an unfair advantage - you’re a ‘Diplom-Informatiker’.
    Glad to hear it was useful.
    Cheers.

  34. Gravatar of 换了个主题 换了个主题

    [...]    现在用的主题是5thirtyone.com的Grid Focus,这么好的主题却不支持widgets,确实比较遗憾,幸好有人已经修改好了,见How to widgetise Grid Focus wordpress theme,具体步骤就是: [...]

  35. Gravatar of Matt Matt

    Thanks for the widget ready instructions. Quick question, how can you create more white space between the widgets?

  36. Gravatar of renet@web renet@web

    Hey Matt,
    Don’t know, plus I am not using that theme. Post the link to you grid focus site and I’ll see what I can do.

  37. Gravatar of Matt Matt

    fadedrequiem.com/zoetrope don’t bang it too hard, it’s for a film class I teach, thanks!

  38. Gravatar of Matt Matt

    That did the trick, thanks!

  39. Gravatar of Danny Danny

    Great info! I’m interested in using the Grid Focus theme for my site, but I’m not certain yet whether it will work for my needs.

    Once I implement these changes, will I be able to change the links in the sidebar via the dashboard, or are they still hard-coded? Or do I just need to grab a widget to handle them?

    Also, and I see this question posted above, but not an answer, I’m also interested in adding my pages to the nav bar at the top (instead of just links). How would one implement that?

    Thanks!

  40. Gravatar of Elliott Elliott

    I love the widgets and thank you for posting it. I do have a problem however. In order for my to post updates i need to delete the functions.php file, then post, then upload the functions.php again. In fact i cant even login with the wordpress admin.

    Im also curious about another issue. i have a bible verse of the day widget and it does no change each day… im curious if this is related.

    Any thoughts?

  41. Gravatar of renet@web renet@web

    Sorry Elliott, but I do not use that theme anymore and I must say I never encountered the issues that you are having.
    Having to reload the functions file everytime certainly seems drastic!

  42. Gravatar of daniel daniel

    Hi is it possible to make the postimgae show up? and just not text, I want to post videos or photos, and it seems kind of disturbing having to click the title of the post, any ideas?

    THANKS!

  43. Gravatar of renet@web renet@web

    The short answer is yes.
    I assume that you are posting the excerpt of the message, hence the reason why you are not getting an image where you expect one. You just have to change the function used to output the message to something like the_content instead of the_excerpt.
    Rgds.

  44. Gravatar of Josh Josh

    anybody know why my text is so tight on the sidebars. I’d like some space between widgets and between the title on body copy of my text widgets.

  45. Gravatar of Josh Josh

    Also, can’t get the RSS widget to work. Says it can’t find my feed address.

  46. Gravatar of laurent laurent

    this hack is great but I would like it to suit the theme bettter fir that I would need to be able to space the widgets a little more, can it be done via CSS? thanks a lot for the help

  47. Gravatar of laurent laurent

    I am working with lots of asian character posts and I got this error “Warning: Cannot modify header information - headers already sent by (output started at /homepages/44/d194959663/htdocs/journal/wp-content/themes/grid_focus mod/functions.php:3) in /homepages/44/d194959663/htdocs/journal/wp-admin/theme-editor.php on line 55″
    and all asian character are gibberishwhich is unfortunate because the widgets seem to work fine.

  48. Gravatar of Marco Marco

    Changing took less than a minute… too bad.. as I finished editing my files i saw that you offer them as a download :| lol

  49. Gravatar of Shafaat Awan Shafaat Awan

    Great guy you were, you solved my problem. I did anything right in Ist try, I wanted to creat website showcase like cssremix, cssmanic etc. Soon I will upload this.

    I am really thankful to you.
    Thanks
    Shafaat Awan

  50. Gravatar of Marco K. Marco K.

    Well explained and easy to do! This is my first try at editing a theme.

    Many Thanks.

  51. Gravatar of nicole nicole

    Thanks you so much!!!!!

  52. Gravatar of Werd Werd

    This worked, Thanks!

  53. Gravatar of SMASHINGAPPS.COM SMASHINGAPPS.COM

    Good theme.

  54. Gravatar of Bradley Woods >> Conceive, Believe, Achieve Bradley Woods >> Conceive, Believe, Achieve

    This article is a god send. This was exactly what I was looking for to improve my grid focus site. I got the widgets working in the sidebars but they are not displaying correctly for some reason. Any idea?

  55. Gravatar of Bradley Woods >> Conceive, Believe, Achieve Bradley Woods >> Conceive, Believe, Achieve

    It looks like whatever is in the first sidebar is also place in the second one as well.

  56. Gravatar of renet@web renet@web

    @Bradley, I just checked your site - things looks OK to me.
    Can you be more precise?

  57. Gravatar of Bradley Woods >> Conceive, Believe, Achieve Bradley Woods >> Conceive, Believe, Achieve

    Sorry about that RENET. I figured out what was wrong after I posted the comment. This is an amazing post I am very grateful that you made this so clear. kudos!

  58. Gravatar of Grid Focus WordPress Theme | Blog Themes Plus Grid Focus WordPress Theme | Blog Themes Plus

    [...] Widget Ready: No (tutorial to make it widgetised) [...]

  59. Gravatar of Michael Oeser Michael Oeser

    Awesome, Dude…it REALLY took less than five minutes

  60. Gravatar of Josh Josh

    Hi, I am a newbie with Grid Focus. My pages do not show up in the nav bar automatically as they do with other themes (There are just link tabs). Also, my site has a small banner that I would like to retain. How do I get that into GF? Thanks for your help.

  61. Gravatar of Claudio Claudio

    Hi, I’m trying to add a flickr widget from http://donncha.wordpress.com/flickr-widget/ in the grid focus theme but it won’t show pictures, I’ve already widgetize the theme but it won’t work, thanks for any help.

  62. Gravatar of honeymoonchild honeymoonchild

    for those ones who wanted to get a white space between two different widgets:

    it’s really simple, you have to work on functions.php.. i’ll give you the code

    ”,

    ‘after_widget’ => ”,

    ‘before_title’ => ”,

    ‘after_title’ => ”,

    ));

    ?>

    all i’ve done was just adding a before the title..if you wanna more space between the title and the widget, do the same thing after

    mic.

  63. Gravatar of Graham Smith Graham Smith

    Greetings,
    Bit late on the scene here, but after giving this a shot I just needed to drop a line and say ‘Many thanks’.

    This is a perfect addition to what seems a very smart theme. Only came across it this morning, and immediatley located your site after finding out about the widget status.

    Instructions are clear and concise.

    It works on WP 2.3.1.

    Thanks again,

  64. Gravatar of Fredrik Fredrik

    I use the exact code that you are suggesting and call it ‘functions.php’

    I get the following error message though:

    Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /wp-content/themes/grid_focus_public/functions.php on line 7

    Parse error: syntax error, unexpected T_IF in wp-content/themes/grid_focus_public/functions.php on line 8

    What am I doing wrong?

    Thanks a lot for all your work!

  65. Gravatar of Jay Jay

    Just wanted to add another thanks. Your guide was very helpful

  66. Gravatar of renet@web renet@web

    Thanks Jay, much appreciated

  67. Gravatar of Abhijit Abhijit

    AWWWWWSSUUUUMMMMM!!!!

    Thanks, you just saved me a few hours of back-breaking coding :D

  68. Gravatar of gofree gofree

    Works perfectly, the only problem is not grid with link in the sidebar like the original:
    http://5thirtyone.com/grid-focus

    This should be:

    Categories
    ___________________________
    Wordpress-Hack
    ___________________________

    Is there any fix this?

  69. Gravatar of Jack Jack

    Hi,

    thanks for this, very concise. And Pascal kudos on replying to so many of your readers :)

    I don’t know if anyone knows, but I am wondering how to get the horizontal scroll bar working - http://www.lazytrainer.org when I dont have it maximised the 3rd column automatically gets moved below the second.

    Any tips would be greatly appreciated!

  70. Gravatar of mnrman mnrman

    It works on WP 2.5 using the latest Grid_Focus theme. Thank you!!

  71. Gravatar of Andy Andy

    Thanks for the easy TUT.

    Here is how I added some white space between the widgets.

    I edited the functions.php by adding. Simple tag. see below. Might be an ugly hack but it works.

    ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ”,
    ‘after_title’ => ”,
    ));
    ?>

  72. Gravatar of Andy Andy

    Damn it didnt show my html tags. I used the tag. Before the first tag and after the last

  73. Gravatar of Tobi Tobi

    Hey, i wonder how i can make the widgets look like the links in the original theme.

  74. Gravatar of wembley wembley

    thank you very much. thank you. thank you. thanks to your simple steps it took me 16m44seconds and 89/100 to do this.
    :) all the best, wembley@twitter

Leave a Reply