May 25

This is a guest post from Margaret Saunders who is a web hosting consultant for IXwebhosting, a web hosting company based in Ohio.

Of all of the content management systems available for free on the Internet, WordPress has consistently been shown to be one of the best over and over again. While WordPress has thousands of themes and plugins that can be used to customize a website and provide additional functionality, sometimes webmasters will want to do something that there isn’t a plugin for, or they will want to do it by themselves without having to add a plugin. In these instances, they have to turn to WordPress hacks. What follows is a list of some of the most popular and most important WordPress hacks.

WordPress Hack #1: List recent comments.
There are a few plugins that allow webmasters to display the most recent comments posted on their WordPress sites, but these plugins are usually confined to the sidebar. With a WordPress hack to list the recent comments on a site, the recent comments can be shown anywhere on the page, including inside of a post. Add the following code to your functions.php file.

<?php
function recent_comments($src_count=10, $src_length=60, $pre_HTML='<ul>', $post_HTML='') {
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,
SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC
LIMIT $src_count";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {
$output .= "<li><a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "\" title=\"on " . $comment->post_title . "\">" . strip_tags($comment->com_excerpt) ."...</a></li>";
}
$output .= $post_HTML;
echo $output;
}
?>

Whenever you want to add the recent comments, just add this code:

<?php recent_comments(); ?>

WordPress Hack #2: Pull the first picture from posts.
WordPress’s home page, the search pages, and the archive pages are all capable of displaying only a small portion of a number of posts in a list. While there is no built-in option for these lists to automatically display the first image from each post, it can be easily done with a WordPress hack, and it looks great. To implement this hack you need to edit your functions.php file in your theme and implement this code:

function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img .+src=[\'"]([^\'"]+)[\'"].*/>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];

if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}

In case you have a post that does not have an image, don’t forget to implement a default image on line 10. Now, you can simply call the function within the loop to display the first image from the post.

<?php echo catch_that_image() ?>

WordPress Hack #3: A print button on posts and pages.
Lots of plugins are available that give someone the ability to easily print the content from WordPress posts and pages. However, a lot of these plugins subject the readers to advertisements. Instead of imposing this on the readers, it can be a better option to use a WordPress hack to create a print button that will take the reader directly to the print dialog window. To do this open your single.php file (for individual posts) from the theme folder and add the following code:

<a href="javascript:window.print()" rel="nofollow">Print this Page</a>

WordPress Hack #4: Automatically include the author’s information with each post and page.
On article directory sites, there is often a resource box at the bottom of each article that gives a brief description of the author of the article. Along similar lines, it’s possible to make a box of information about the author appear with every post or page on a WordPress site using WordPress hacks. For this you’ll need your Style sheet and add this to it:

.postauthor {
}

Then you’ll need to go through your index.php file within your theme and look for a similar code like this:

<?php the_content('Read the rest of this entry »'); ?>

Above this code you implement the following:

<div>
<?php the_author_description(); ? >
</div>

All that is left to do now is to add your own style to format the about author box.

WordPress Hack #5: Buttons to send posts to Facebook or Twitter.
The two most popular social networking sites are Facebook and Twitter. Because of their popularity, it’s very important that a website is integrated with both platforms. With a WordPress hack, buttons can be added to send a post or page from WordPress directly to Facebook or Twitter without having to configure some annoying plugin. For the Facebook button add this to the loop in your single.php file in your theme.

<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="blank">Share on Facebook</a>

For twitter add this to your loop:

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a>

In Conclusion
Just because there is a plugin for a feature in WordPress, that doesn’t mean that, it’s good enough to make people want to use it. Many people enjoy doing things themselves so that they have full control over what is added to their websites. These people often prefer WordPress hacks over WordPress plugins because of the sense of doing it themselves and accomplishing something important. The six plugins listed here are good examples of people taking matters into their own hands when it comes to their WordPress websites.

For further questions and suggestions don’t hesitate to contact me.

Margaret Saunders
margaret.saunders@ixwebhosting.com

\\ tags: , , , , ,

Mar 11

Images of blog consume a significant portion of the bandwidth. Many shared hosting providers impose bandwidth and CPU usage limits, which may be reached quite easily if your site has significant amount of images in it. Some providers also kill the processes if they are CPU intensive causing your blog to throw errors.

I heard about using Dropbox’sPublic” folder to host static content of websites. I have searched on the net and found that there is a WordPress plugin to host theme images. Also, there is a plugin to sync the images of WordPress and load them from Dropbox, though it is not working with the latest version and throwing up lot of errors. I searched the WordPress plugin repository to see if I can achieve the same with any other plugin.

I came up with the following idea, implemented on few blogs of my clients, and now the image bandwidth usage is down to only “few MBs.” Also, the blogs are loading faster.

First, create a free account on Dropbox. It gives you 2 GB free storage.

Install the “Real-Time Find and Replace” plugin from dashboard. It will replaces the code and text from themes and other plugins with your chosen text dynamically.

Offloading WordPress theme files to Dropbox
In Dropbox’s “Public” folder, upload your theme folder retaining the directory structure. Upload only CSS and images. Look at the screenshot. I uploaded the “Pilcrow” theme.


Obtain the public link of CSS file by right clicking on the file and selecting “Copy Public Link.” It will look like this: http://dl.dropbox.com/u/1234567/pilcrow/style.css. From this URL, we can understand that, our theme folder on Dropbox is “http://dl.dropbox.com/u/1234567/pilcrow

Now, the real magic happens. Go to the Tools>Real-Time Search and Replace. Click the Add button and you will see two boxes, Find and Replace.

Now, browse your blog and see the source of webpage (Ctrl+U in Firefox). Your theme CSS URL will look like http://www.yourblog.com/wp-content/themes/pilcrow/style.css. Enter that in first box and replace URL will be http://dl.dropbox.com/u/1234567/pilcrow/style.css.

That’s all. Now, your entire theme images and CSS will load from Dropbox.

Offloading all the uploaded images to Dropbox
*. We know that all the uploaded images and files are stored in “wp-content/uploads” folder. Go to Dropbox’s “Public” folder and create a folder “uploads.” Download all the files in your blog installation’s “wp-content/uploads” folder and upload them to Dropbox’s “Public/uploads” folder that we just created.
*. Obtain the link of that folder by right clicking on an image. See above to see how we have done. It will look like “http://dl.dropbox.com/u/1234567/uploads/some.jpg.” From this URL, we can note that the link of this folder is “http://dl.dropbox.com/u/6784327/uploads
*. Now, in “Real-Time Search and Replace” settings, add like this:
Find: http://www.yourblog.com/wp-content/uploads/
Replace: http://dl.dropbox.com/u/1234567/uploads/

That’s all, all images will now be served from Dropbox.

Important Note: When you create new posts, you need to upload those images into Dropbox’s uploads folder as well. If you are organizing uploads into months and years folders, then you need to retain the structure in Dropbox’s uploads folder too.

If you want to upload files to Dropbox without leaving the WordPress dashboard, consider using The Dropbox Plugin.

If you exceed the 10 GB public folder bandwidth of Dropbox or run into any problems, just deactivate the plugin, and all images will be served from your host.

Dropbox is a file syncing and sharing service. You can use it for storing files and documents and can sync them across all the computers you use. Even, you can sync the files into your smart phones like iPhone, BlackBerry, and Android phones.

\\ tags: , , , , ,

Nov 17

Open Source Today, I was thinking to develop two WordPress sites for the upcoming projects of mine.  While searching for the good themes, I recalled that Revolution themes have become open source.  So went to http://www.revolutiontheme.com/ and it redirected me the http://www.revolutiontwo.com/. Site was looking nice.  I browsed through the site, but unable to see any download link.  What I was seeing was $99.95/year Pro Package and $149.95/lifetime Pro Plus Package.  I thought that being open source these themes will become free for download.  Clicked the support link to see if there is a link, in vain.  It was telling me that I should sign up to see the threads.  Surprised!  Should I need to signup to get these themes? Confused!  It is approx 100 dollars, which I can’t afford.

So, opened Google and asked “Big G” to show the way to “revolution wordpress themes download” and landed on http://www.wphacks.com at this post http://wphacks.com/revolution-wordpress-themes-2/ The post was showing Revolution themes with links to download.  When I clicked on the link it has gone to e-junkie and returned to the homepage of RevolutionTwo.com.  It was frustrating.  So I had to go through all the comments of wphacks’ post to see if anyone is having the same problem and stuck at a comment where a guy was having the same problem.  What he was seeing was just the signup links like me.  Kyle Eslick commented that he should see a download link in small text.

Kyle Eslick's comment at WPHacks

Then I returned to the site and now I can clearly see the download link, which is in very small font and was looking like a footer note.  So, it took half an hour for me to find the download link.

Theme download link, which will be ignored as footer link

Theme download link, which will be ignored as footer link

After downloading the theme, I opened the zip file and found no instructions on setting up the theme.  Again I went to support site and was able to get a little details on setting up the themes, one or two threads, which are open to anyone.

So, what I want to say is:

  • Though it says Open Source, I don’t see the things like what I see on many open source sites.  Site is misleading the visitors making them to sing up for the 100 or 140 dollars membership, looks like playing a cheap trick to get signups.
  • Why don’t you people put the download links more prominent rather than making it look like footer links?
  • Why there is no setup guide in the themes?

Read the below comment by DerFrankie at WPHacks, that is what came into my mind after half an hour search.

I think, that the way Revolution is doing this is quite the oposite of open source.

You might think that a normal open source project will focus on developing a product (theme), documentate it, and release it as a base for contribution and a community to build upon it.

To monetize the effort of the releasing firm, some firms offer service and support agreements (btw a new forrester research has shown that most open source projects relying solely on support contracts don’t pay off).

I cannot see this with this themes. The site states that is open source – but it’s main goal is to sell the service.

On the site you have to “search” for the download link. There is no “project” behind it and the customization has to be done, by “hacking” into the theme, making it difficult to upgrade.

And, many more questions, but when somebody is offering things for free, we can’t question them.  Anyway, if you want to download a theme and use it for your blog, below links will be helpful:

  • Download links are at the bottom in small font as you can see in the image above.
  • Theme tutorials are here: http://www.revolutiontwo.com/support/viewforum.php?f=14 though they do not cover all the things.
  • Go to Justin Tadlock’s http://themehybrid.com/ and you can find few free themes similar to Revolution. Read the documentation and experiment with those themes.
  • Play with Darren Hoyt’s Mimbo theme to understand setting the categories and custom fields.
  • Now, go to Dashboard>Theme Editor and edit the theme files to setup the themes correctly.
\\ tags: , , ,