WordTwit Fails When WordPress Blog is Installed in Subdirectory
WordTwit is a very handy plugin for WordPress blogs that automatically publishes your blog articles to a selected Twitter account. Twittering your blog posts is a great way to promote your blog and reach a wider audience.
There are at least a dozen Twitter plugins for WordPress. But what makes WordTwit special is it uses shortened URLs generated from your own domain, rather than a third-party URL-shortening service like bit.ly or tinyurl.com.
For example, a recent article at our blog DevTopics has the WordTwit shortened URL http://devtopics.com/iz. The advantage of using your own domain is it helps promote your site, allows “link juice” to pass to your domain instead of a third-party service, and gives people confidence that clicking on the link will take them to your blog and not a spyware or attack website.
Unfortunately, even though WordTwit is already up to version 2.1.6, the author has not yet fixed a glaring bug: WordTwit-generated links fail when your WordPress blog is installed in a subdirectory. If your blog is installed in your domain root, WordTwit works fine. But if it’s installed in a subfolder, such as http://www.eye-4-style.com/blog/, then clicking on a WordTwit-generated link results in a “404 Not Found” error.
But some smart users on the BraveNewCode forums have discovered a workaround. It requires you to edit the core WordTwit code file, which means this fix will break every time you upgrade the WordTwit plugin. Here are the steps, assuming that the WordTwit plugin is already installed on your blog:
1. Login to the Admin panel of your WordPress blog.
2. Go to the Plugin page.
3. Find the WordTwit plugin in the list. Click the Edit link under the WordTwit plugin name:

4. Edit the wordtwit/wordtwit.php file.
5. Scroll down to find the line that says “$url = $_SERVER["REQUEST_URI"];”
6. Insert the code as shown below and click the Update File button. The existing lines of code above and below the new code are included so you know exactly where to add it:
// check TinyURl
$url = $_SERVER["REQUEST_URI"];
// strip off blog directory
$blogurl = get_bloginfo('url');
preg_match('/^https?:\/\/[^\/]+(?<path>\/.+)$/', $blogurl, $blogpath);
$blogpath = $blogpath['path'];
if (($blogpath !== '/') && (strpos($url, $blogpath) === 0)) {
$url = substr($url, strlen($blogpath) -1);
}
if ( strlen( $url ) < 6 ) {
Recent Entries
- How to Install and Setup Windows Live Writer
- Web Publishing is a Different Paradigm
- WordTwit Fails When WordPress Blog is Installed in Subdirectory
- Cannot Activate Feedburner Email Subscriptions
- How to Find a Domain Name
- Top 25 Most Valuable Blogs
- Most Expensive Domain Name Sales
- How to File a DMCA Complaint
- Splogs: Spam Blogs and Stolen Content
- Can you Digg it? 7 Tips for Bloggers Working with Social News Sites
