Embed Facebook Fan Page Photo Albums In WordPress

January 8, 2010

It is a great idea to have a Facebook fan page for your company, club or organization.

This is a minor hack of the Fotobook plugin for WordPress by Aaron Harp. Fotobook is originally meant to apply your personal photo albums into WordPress, but we’re going to make one small code tweak to instead pull the albums from the fan page that we administer.

After installing the plugin, go ahead and activate it and grant the permissions to your Facebook account.

Next, visit your Facebook fan page, and click into an album so you’re viewing all photos in one particular album. In the address bar you’ll see a &id=123123123. Copy that ID number.

In the plugin directory open the fotobook.php file and head down to line 243 and look for this code.

$uid = $session['uid'];

Swap that code for this

//$uid = $session['uid'];
$uid = 123123123;

With the 123123123 being the ID code for your fan page.

If you have a custom URL set for your fan page you might notice that the album photos are not showing. To correct that move down around line 809 in fotobook.php and look for:

if(!is_numeric($id)) return false;

And code it out of use by adding // in front so that it now looks like

//if(!is_numeric($id)) return false;

Back in the plugin administration page, go ahead and import your albums. And you should be good to go!

With a thanks to B. Thibault in the forums at the Fotobook Application Page.

Remove and Prevent Revisions in Wordpress

June 17, 2009

I recently noticed that a particular post had built up about 10 or 15 revisions for it. I started thinking that of all the posts I have, there have to be quite a few revisions and therefore are creating a hefty sized table in my database. This was run on my WP 2.8, but should work for 2.6 and up.

Here is a solution to prevent revisions from being created, as well as removing all revisions from your database.

Prevent Revision Creation

Open wp-config.php and add this to the very bottom of the file, before the php closing tag.

define('WP_POST_REVISIONS', false);

This completely turns off any revision creation. If you’d like to restrict revision creation to a set amount per post, you can change ‘false’ for the number of revisions you’d like stored.

Remove All Revisions From Database

Open up your database in phpmyadmin and run this SQL Query.

DELETE FROM wp_posts WHERE post_type = "revision";

And now you’ll have a more tidy database.

Install Wordpress On a Local Server

April 15, 2009

In this tutorial, we’ll go through the process of setting up a server on your local computer. This will allow you to run PHP & MySQL applications, such as Wordpress, directly on your machine.

As I have yet resisted joining the ranks of the Mac cult, we’ll be using PC server software. I am aware of XAMPP, WAMP, and I personally use VertrigoServ for no other reason than it is the only one I’ve tried. (Mac cultists can use MAMP.)

This Tutorial Is Based On VertrigoServ

They say that cleanliness is next to godliness, and in that vein let us install our server in a organized location. On my desktop, I actually use a whole separate hard drive to store my server. If you don’t have the luxury of a dedicated HDD, then your local disk or C:\ will be fine.

01. Installing The Server

Create the following directory: C:\usr\. Then run the server installer, and be sure to install the software in the C:\usr\ location. If you installed the VertrigoServ software, then the “public web” files will be located in C:\usr\www\. So let’s download and install Wordpress inside C:\usr\www\wordpress\ and then be sure to fire the server up after installation.

02. Setup The Database

So we’ll need to have a database created before we can install Wordpress. In your web browser, navigate to http://localhost/phpmyadmin and login. There should be the default user and password if this is your first time. Find it by clicking the VertrigoServ icon in the bottom right tray, and selecting “Help and Readme”. Be sure to change your passwords once you get in. Default login is root/vertrigo.

Now that we’re in PHPmyAdmin, let’s create a database for our local Wordpress install. Type in your desired database name, and hit the “Create” button.

wpdb-create

03. Installing Wordpress

With the database created, we can now input our database details into the wp-config.php file of our WP install.

1
2
3
4
5
6
7
// ** MySQL settings ** //
define('DB_NAME', 'database_name');    // The name of the database from step 2
define('DB_USER', 'root');     // Vertrigo uses root as the default username
define('DB_PASSWORD', 'vertrigo_password'); // the password used to get into your local phpmyadmin
define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

Now we can pull open our browser, and navigate to http://localhost/wordpress and begin the installation of Wordpress.

The http://localhost/ address looks into the \usr\www\ directory. So whatever the name of the directory we installed in, is what we’ll need to punch in after localhost/. For example, if I installed an application in \usr\cms\, I will need to navigate to http://localhost/cms in order to pull up that site.

Web Design Tricks

January 28, 2009

Here is a round up of some very useful tricks and snippets for web designers.

Comment Design For Wordpress 2.7

January 14, 2009

If you’re a Wordpress theme developer, I’m sure you’ve run into the problem of styling, and altering comments in your theme. Now that comments are called through a loop to allow for the much anticipated threaded comments feature, we’ll have to make use of our function file to style the comments.

If you’re like most every other developer, the first thing you want to get rid of is the “says” that follows the authors name. Now we can do it, without having to set the CSS to display none.

01. In your theme directory, open up functions.php. If you don’t have this file, go ahead and create one.

02. Let’s create the function ‘mytheme_comment‘ and paste it into our functions.php file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
function mytheme_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>
         <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
      </div>
      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.') ?></em>
         <br />
      <?php endif; ?>
      <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','') ?></div>
      <?php comment_text() ?>
      <div class="reply">
         <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </div>
     </div>
<?php
        }
?>

Looking at this code, you can see exactly what you want to do to style your comments accordingly. After you’re happy with how you want it, the next step is to create the callback from our ‘wp_list_comments’ in the comments.php file.

03. Open up comments.php in your theme directory, and search for wp_list_comments. Control + F should make short work of that.

The default theme has this exact call:

1
<?php wp_list_comments(); ?>

So we’ll just use the function name that we created in step 2 (mytheme_comment), and call it as a variable:

1
<?php wp_list_comments('callback=mytheme_comment'); ?>

And now, we’ll see the styling reflected in our comments!

Separate Comments From Trackbacks

And for another good tip, you should separate your comments from your trackbacks. It’s just good manners.

In your comments.php file you can create two lists, and call the loop twice. Only for each loop, you can specify which type of comment/trackback is called. Example:

1
2
3
4
5
6
7
8
9
	<h3 class="comment_title">Comments</h3>
		<ol class="commentlist">
            <?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>      
		</ol>
 
	<h3 class="trackback_title">Trackbacks</h3>
		<ol id="pings" class="trackback">
			<?php wp_list_comments('type=pings'); ?>
		</ol>

For some complete code, and even some jQuery for a toggle hide switch on the trackbacks, be sure to read the article by Curtis Henson.