Facebook Iframe Fanpage With WordPress and Thesis

by David Alexander in Social Media

Facebook has been going on about the depreciation of FBML for quite some time now, and over the past few days some of this has come into effect with the ability to add static fbml to new fanpages being removed. Note: This doesn’t effect current fanpages using fbml.

The replacement is the usage of iframes and really isn’t something I have bothered to look at until the other day but thought it may be useful to Pixelloop.

The Brief

A client of mine had asked me to take a look at a wordpress theme that came out recently which pretty much just provides the frames for you to use, and some instructions, as the client wouldn’t want to change from the Thesis theme just for this one feature the alternative was to create a new subdomain and put a fresh install of WordPress on that to use it.

The Solution

It seemed a bit overkill to me and so I set out to do it without changing themes and use thesis with a custom template and a custom body class to apply some specific styling etc.

The Ingredients

- WordPress 3.1

- Thesis 1.8 (Though most of this should work with any wp theme if adapted to suit)

- Some Custom PHP and CSS for Thesis.

- A Facebook fanpage (For Testing)

- A Facebook App

Step 1

I am going to presume for the sake of this post getting too long and going over things already well documented online that you have WordPress and Thesis or any other theme you plan to adapt this to installed and setup etc. I am also going to presume you are familiar with the process of creating a new fanpage, however will provide some tips.

REMEMBER: All images within this tutorial can be clicked to zoom in and see closer.

Facebook Fanpage

In case you haven’t already made a fanpage as mentioned above, and are confused by the ever increasingly overwhelming and constantly changing user experience of Facebook you can go to Create a Facebook Fanpage… but wait….

Do NOT create a community / Causes fanpage, unfortunately these fanpage types do not support the ability to set the landing tab of your fanpage to a custom tab of your choice. ( We plan to use your new facebook iframe app). This will be a pain in the neck when you come to turn it on at the end and realize you have to create another fanpage. (See Image Below)

Once the fanpage has been created we can leave that for the time being and will return to it once our app has been created and we have a page to use on our wordpress site.

Facebook App

To create a facebook app you need to go to Facebook Developers which is the main page for everything FB Dev related. Here you can click the Set Up New App in the top right. If you don’t see this button then that is because you haven’t verified, To go direct to the Create an App page click Facebook App Setup. You will then see the below image on your screen and be prompted to name your app and agree to the terms.

Once Create Application has been clicked you are taken to the ABOUT tab of your application. This should look like below, and while none of the settings on this page directly relate to what we are trying to do it is recommended you fill in all fields and make use of the icon upload feature for your branding. On the below screen once saved, it may take you to your App Main page. Click Edit Settings and you will return to this screen, you will need to do so as the next step is to click the FACEBOOK INTEGRATION tab in the left sidebar.

We will then be prompted with some fields we must populate for the whole thing to work.

So the required fields on the above page are as follows…

- Canvas Page – Simply add a name with no trailing / for your app to reside at.

- Canvas URL – The url of the site we are going to pull our content from. Most of the tutorials I saw were using index.php and other extensions, as WordPress doesn’t use these for its permalink structure we can ignore them and do it the way WordPress would.

- Canvas Type – Needs to be iframe of course, as we are creating an iframe app.

- iframe Size – Tweak to taste.

- Tab Name – This will be the apps tab name when we add it to the sidebar of our fanpage we created earlier.

- The Tab Url – This may or may not show slightly different to different users but ultimately just the page name with a / on the end should do it. In our case we are going to make a page called fb on our site, so this is the one we want to use. Some ways use the homepage but this wasnt flexible enough for me and wanting to control the size of the template being pulled into the iframe.

Then you can hit save changes and your app will be updated. As we haven’t yet created the page on our site that we want to display on the fanpage we better go over to our wp-admin / dashboard and do that.

WordPress

So we have a fanpage ready to use, an app configured to our site and a page on it. This is where peoples usage will differ. I will justify why I used this approach, though there may be a few. I wanted to have the fanpage for this site, hosted on this site, and at the same time use wordpress because I wanted to be able to have it as a part of my CMS. I didn’t want to convert to a different theme, or restyle my whole website. So I did two things, use a custom body class, and create a custom template, though the latter isn’t necessary for most as a custom body class alone will allow you to create specific css styling for the fanpage and hide any unwanted elements around your content area, and change the size to conform with facebooks 520px width limit. You can have any height you want, if your width exceeds then a scroll bar will appear across the bottom.

- Create a New Page

We created a new page and named it fb. This means by default wordpress will give it an additional custom body class of .fb so we can apply page specific styling. Alternatively thesis would allow us to give this page any name and then add our fb to the Custom Class Meta Field.Populate your page with content, images, titles, links and whatever else you want, and publish it (You can come back here whenever you like to edit it of course).

- Style Our New Page

As I mentioned above, we have created this page so it has a custom body class of fb and therefore designing this the Thesis way, we will open up custom.css and instead of beginning each style with .custom we shall use .fb instead.

Below is some example css I have used to take this site and remove any elements I don’t want to get the page back to basics. The majority of the div id and classes mentioned in the below code are thesis specific, I have basically hidden a load of elements, like the header, footer, nav, page title etc, and focussed on displaying the content in plain white box with a light grey border. The important bit below is the custom body styling limiting the size of the area in use and setting an overflow:hidden; to ensure no horizontal scrollbar will show.


/* Fanpage Styles */

body.fb {
 background: none repeat scroll 0 0 transparent;
 margin: 0 auto;
 overflow: hidden;
 width: 520px;
}
.fb #title_area {
 display: none;
}
.fb #footer_area {
 display: none;
}
.fb .post_box {
 margin: 0;
 padding: 10px;
 width: 498px;
}
.fb img.right, .fb img.alignright, .fb .wp-caption.alignright {
 margin: 0 0 18px 18px;
}
.fb img.left, .fb img.alignleft, .fb .wp-caption.alignleft {
 float: left;
 margin: 0 10px 10px 0;
}
.fb #footer_area {
 display: none;
}
.fb h1 {
 background: none repeat scroll 0 0 transparent;
 color: #111111;
 font-size: 33px;
 line-height: 33px;
 margin-bottom: 20px;
 margin-top: -25px;
 text-align: left;
 text-shadow: 2px 2px 7px;
}
.fb .headline_area {
 display: none;
 margin-bottom: 0;
}
.fb .format_text h2, .format_text h3 {
 color: #111111 !important;
 display: block;
 float: left;
 font-family: tahoma;
 height: 100%;
 margin: 10px 0;
 text-align: center;
}
.fb .headline_area h1, .fb .headline_area h2 {
 display: none;
}
.fb #sidebar_1 {
 display: none;
}
.fb #bread {
 display: none;
}
.fb #content {
 width: 520px;
}
.fb  #content_box {
 width: 520px;
 text-align: left;
}
.fb .full_width .page {
 margin: 0 auto;
 padding-left: 0em;
 padding-right: 0em;
 width: 520px;
}
.fb #nav_area {
 display: none;
}

Once the above has been added to the sites css or a variant to your own liking we can now preview how the page looks. Mine is shown directly below.

As you can see above, I have added a h2 heading, some text an image floated to the right, and 3 images across the bottom, all of this formatting inside the box has been managed with the wordpress wysiwyg editor. The above in no way resembles the site/blog you are currently reading this article on thanks to the custom css.  You can check this page at Facebook WP Page.

What Now?

The next thing we want to do is head back over to the developer main page at Facebook Developers and on the right hand side we can go back to our facebook application we made. When we get there we need to go to Application Profile Page, I have marked this in the image below with a messy “sorry” red dot.

Once we arrive at the Application Profile Page we want to navigate to the left hand sidebar and add this app to our fanpage. Below I have again used a red dot to show you where the add to page link is, and a red dot to signify the pop up which appears listing all pages you are an admin of, excuse my irrelevant list as I have a tonne. Find your fanpage you created and click the Add To Page button. (See Below)

Nearly there, now we need to click close in the bottom right, and navigate over to our fanpage to check our our new tab, in our case its the Welcome tab at the bottom.

As you can see from comparing the above to the wordpress page before, it is pulling through the exact content from the page. You can visit the fanpage to see it properly with more changes and features since this articles completion go to Pixelloop Fanpage Welcome Tab.

  • Cheryl Currie

    Wow, this is so informative and so needed. Thank you.

    • http://twitter.com/One3rdNerd David Alexander

      Hi Cheryl, Thank you :)

      • http://www.facebook.com/people/Mark-Hockenberry/100000144350714 Mark Hockenberry

        Thanks David for this tutorial. I’ve recently started a facebook fan page, and I love using the Thesis theme for WordPress. My business is new (and website) so I might give this a try sometime soon! Thanks, Mark

  • http://twitter.com/BragInteractive Brad

    Great article, I actually created a WordPress theme that fits perfectly in the iFrame applications on Facebook. If you or your readers are interested you can check it out here: http://braginteractive.com/wordpress-to-facebook-iframe/

    • http://twitter.com/One3rdNerd David Alexander

      Hi Brad, good looking, While I like the solution I feel a theme is overkill for this small hack, there is a plugin Called Facebook Tabs which adds a template to your existing theme to do this. I personally wanted a no thrills version which worked with any theme I wanted to continue using and not rely on a plugin. Good luck with your venture, I like it, but would prefer to see your theme become a plugin. :)

      • http://twitter.com/BragInteractive Brad

        Then you cant make a full blown site within Facebook. Managing you Facebook page with a WordPress with give a user more features. Different styled pages, customizable navigation, a blog section, contact form, etc.

        You just cant do as much with the Facebook Tabs plugin. I see what you are talking about though. Thanks

        • http://twitter.com/One3rdNerd David Alexander

          Very good point you bring up there Brad. I guess my solution was more to make a facebook fanpage and then have all links link out to an actual webpage where they can be tracked and quantified, which of course is impossible within the iframe. So I like both approaches when I look at it from both angles. Nice work!. With a little tweaking the above code I used can be used to create a whole thesis site which means the size criteria.

  • Bill Travers

    Thank you a ton David. People like you who take the time to help others like me are a vital asset to our web marketing initiatives.

    • http://twitter.com/One3rdNerd David Alexander

      Hi Bill, thanks your support is much appreciated. Good luck and feel free to come back and share your results. :)

      David

  • http://twitter.com/nickreese Nick Reese

    David, you absolutely killed it. I love it!

  • http://11elevengroup.com Paul Smith

    Great stuff – thank you. I’ve been watching some changes in this area, and now that a Thesis solution exists, it will make things much easier.

    • http://twitter.com/One3rdNerd David Alexander

      Thanks Paul.

      As Brad (Commenter below mentioned) the above method would do one page, or all pages with the .fb body class, and his theme approach was so you could have an entire site within the confines of Facebook. However if you installed a vanilla install of Thesis, and instead of using .fb used .custom you would be able to achieve either result.

      Have fun, and would love to see your fanpage when you do one, feel free to come back here and link it. :)

  • http://ww.fb.com/iFrameDiva MissEm

    Hi David,

    Thanks for the post – I didn’t even think of using Thesis for a Fan Page, but now my head is full of crazy thoughts about what to do.
    I’m still a traditional coder doing traditional stuff, but this is definitely worth having a play with :)

    Em

    • Anonymous

      Your welcome, I would love to see your results.

  • Anonymous

    Let’s not forget to add the proper code that auto-resizes the page and allows you to see the complete page.

    • Anonymous

      Good point, there is a setting on the fanpage app to allow for auto resizing or not. I have used both approaches.

  • Projext

    Excellent article.

    One thing I can’t do is make the page open up at the welcome tab?  Is that possible?

    It used to be under view settings but I can’t see that?

    • Anonymous

      This depends on if your page is set to community page or causes, both of those don’t support the custom welcome tab option, so you must when creating a new page make sure you don’t set it as a community page. A few people have had this issue.

      • Projext

        I think you misunderstand.  I have the welcome tab and its great..I just want the page to open on that tab.

        I remember in the past there was view settings that allowed you to to do this….?

        • Anonymous

          I understand perfectly well Projext,

          1 – Community or Causes fanpage types do NOT support that feature.

          2 – Fanpages which do can be set by going to “edit page” and wall settings. It should appear there to set the landing page of your fanpage to any of the tabs added.

          3 – As the admin you will NEVER see this, but all other normal fans and none fans which land on your fanpage will. So always have a spare facebook account you can use to see how it appears to the end user, as opposed to the admin.

          Hope that helps.

          • Projext

            Thanks for the reply.  I have double checked the old one and even created a new local business page just to try it.

            I just don’t seem to have wall settings when I edit page?

  • Confused

    This is absolutely awesome. Unfortunately, I’m running into some problems…

    Here is the page I’m trying to customize:

    http://brewers1982.com/card-of-day-topps/

    It’s close, but with some issues:

    1) border on the left and right need to go away
    2) padding on left and right need to go away (unless it’s centering and needs to align left)
    3) scrolling shouldn’t be completely removed because now I can’t get to content at the bottom.

    I’m not a coding expert, so any details on specific code for custom.css would be greatly appreciated!

    • Confused

      So, I figured out #1 and #3, but still having issues with #2. Thoughts?

      • Anonymous

        Looks like your padding is okay now, can you send me the fanpage url? Once suggestion I may have which would make your fanpage cool, install shadowbox js plugin and use it with your card images so when clicked they open a pop up which zooms to fit the screen but keeps the user on the main page? If its applicable of course. :)

        • Anonymous

          Here it is…

          http://www.facebook.com/brewers1982?sk=app_210779288958037

          You’ll notice that my problem now is that it scrolls vertically instead of auto-resizing, even though that option is selected.

          I love your idea about Shadowbox JS! I installed it, but may need some direction on how to use it. Nothing currently happens even though it’s activated. Any specific settings I need to use?

          Many thanks!

          • Anonymous

            Hmmm, yeah its odd, I am trying to dig out the info on the auto resize stuff and will post back.

            To use shadowbox on any image link or normal text link you simply need to give each element a rel= I presume you have heard of rel=”nofollow” ? Well if you add rel=”shadowbox” to each image’s link so you have ahref= first then each image or text link with that new addition will open using shadowbox js. Also check the settings to make sure all formats are selected and you may also need to choose a js library like jquery.

            Cheers, let me know if you get stuck.

          • Anonymous

            That’s awesome! I’ve made the first two images open with Shadowbox. Anything I can do to make them align top or center more on my screen? I’m on a 13″ MacBook Air, which could be part of the problem, but when I cli k on an image it brings up the overlay that is mainly black space up top and then you have to scroll down to see the image. But really nice.

            I’ve seen a couple of tutorials that may solve my problem with the scrolling. That’ll be my next step.

          • Anonymous

            Glad its sort of working for you. I guess it centres it vertically to align central also and therefore that is happening, however perhaps with the scrollbars fixed it may have a knock on effect and fix the shadowbox alignment. If you use firebug with firefox you may be able to inspect and find which bit to edit in the custom.css

  • Kumar Aspx

    Thank you for the detailed explanation i am working on making one . can you please tell me how to display the fans only content and non fans content. i saw some pages are hiding a div like the following click here to like for fans. how to do this?

  • http://www.facebook.com/rpintorj Rodrigo Pinto

    Now it’s require a SSL protocol

  • http://www.facebook.com/elle.billias Elle Billias

    Hi, how would you add some fan-only content in a widget area?

  • http://worthessays.com/ Mhoro10

    Hello,
    Although it was not straight forward, I have finally managed to create a unique facebook page.

  • http://thenewergonomics.com/ Chris

    I’m trying to follow along here, but it looks like things have changed a bit since this tutorial was written. I seem to be good, until I go over to the app page, and then I don’t see any option for adding it to my Fan Page.
    Any thoughts?

    Here’s the App Page:
    https://apps.facebook.com/thenewergonomics/

    And the Fan Page:
    https://www.facebook.com/TheNewErgonomics

    I’m soooo close…

    Chris
     

  • Beth Reeths

    Any input on what to modify to get rid of scrollbars?

Previous post:

Next post: