WarpConduit Computing

  • Quick Tips
  • Web Development
  • WordPress Plugins
  • Home
  • Passphrase Generator
  • Password Generator
  • About
  • Contact

Fix Redirection and Error Page On Empty WordPress Search

August 2, 2011 by Josh Hartman

I found out just recently that in some cases when you perform a blank search on a WordPress site you are redirected to the front page with an error message. If you encounter this issue simply apply the fix below, which modifies the blank search into a search for one space. This is enough to resolve the error page and land you on the search page.

Add the following code to your theme’s functions.php file to fix this annoying behavior:


if(!is_admin()){
	add_action('init', 'search_query_fix');
	function search_query_fix(){
		if(isset($_GET['s']) && $_GET['s']==''){
			$_GET['s']=' ';
		}
	}
}

Filed Under: Web Development Tagged With: error, redirect, search, wordpress

Setup WordPress to Respond to Multiple Site URLs

July 23, 2011 by Josh Hartman

Have you ever encountered a case where you want to access your WordPress site from multiple site URLs (for example a local URL and an external URL, or multiple external URLs)?

Solution

Change the Site URL and Home URL to a relative URL, making the domain name irrelevant to loading the site. Oh, but it can’t be as simple as updating that on the Settings->General admin page, no…WordPress requires a valid URL. Well don’t give up, you’ll just have to hack the option directly in the database.

  1. Connect to your WordPress database using a web-based utility like phpMyAdmin or another SQL client such as HeidiSQL.
  2. Open your wp_options table for editing (if applicable, use your table prefix instead of wp_).
  3. Find the rows with an option_name of siteurl or home and change the option_value of each to / if WordPress is installed in the root of your website or /path/to/wordpress if your WordPress site is installed in a sub-directory. Do NOT add a trailing slash.
  4. For those wanting to execute a simple SQL query, here is an example:
    
    UPDATE wp_options SET option_value = '/' WHERE option_name IN('siteurl', 'home');
    
  5. Test your site out by going to your site URLs (for example http://192.168.0.1, http://mywebserver.local, http://www.example.com).

Important Note: This method is a hack and therefore isn’t a behavior WordPress developers intended. I wouldn’t recommend it for a production site. I have noticed that after making this change on a site that the admin login page lacks CSS, the toolbar on the Visual Editor is missing, and the front-end admin bar sometimes fails to be styled and shows at the bottom on pages. I haven’t seen any issues with the normal front-end site that visitors see. So be aware of some admin CSS problems.

Hope that tip can help some of you out, I know it was useful to me.

Filed Under: Web Development Tagged With: url, wordpress

Speed Up WordPress Using Cache & Compression

November 8, 2010 by Josh Hartman

There are so many plug-ins designed to speed up WordPress, but which ones actually work? I’ve taken the time to try out some of the more popular plug-ins and found the most efficient solution on my eyes.

Cache Plugin Comparison

Before going into the procedure of installing my preferred cache and compression solution I’ll share with you my findings between some of the most popular cache and compression plugins.

  Control W3 Total Cache WP Super Cache Quick Cache W3TC + Scripts Gzip WPSC + Scripts Gzip QC + Scripts Gzip
Page Speed Score 78 79 77 77 88 85 85
YSlow Score 73 81 73 75 91 85 84

Testing: I used Mozilla Firefox 3.6.12 with the Firebug, Page Speed, and YSlow add-ons. For each combination I would load the page first without cache (Ctrl+F5) and then refresh the page a couple times, and then finally run Page Speed and YSlow to get the scores. I had done load time tests for each combination as well, but decided to not publish them because of inconsistent results, perhaps due to the site being on shared hosting and my wireless Internet connection.

Winner: While all plugins perform well, W3 Total Cache took first place because of it’s wide array of options and out-of-the-box performance rating from Google Page Speed and YSlow.  Paired with Scripts Gzip W3TC blasts past the other plugins.

Step 1: Prepare for Installation

  • Disable all PHP output buffer handlers – open your PHP.ini and make sure that output_handler = Off and zlib.output_compression = Off, this will prevent double compression resulting in garbled output to the browser
  • Remove any mod_deflate and any old rewrite rules from .htaccess – try to leave only the standard WordPress rewrite rules and your custom rewrites
  • Deactivate and delete any previous caching plugins – start fresh and free of clutter
  • Optimize your WordPress database – decrease database bloat

Step 2: Install W3 Total Cache

  • Login to your WordPress admin interface, click Plugins on the admin menu, and then Add New
  • This will present you with the Install Plugins screen, type “w3 total cache” into the search box and click Search Plugins, and then click Install Now under the entry for W3 Total Cache
  • After Installation has completed go ahead and activate the plugin

Step 3: Configure W3 Total Cache

This plugin has lots of options, but it’s still pretty easy to configure. Let’s get started by clicking on the the Performance admin menu item. Now, the default options are great, but let’s at least go ahead and enable Object Cache and Save changes , then go into the Browser Cache settings and under the General section enable Expires headers, Cache Control headers, eTags, W3 Total Cache header, and Gzip Compression and Save changes.

Click on the Performance menu item to get back to the main options and where it says Preview Mode click Disable.  After the page reloads click Empty all caches to clean everything up.

Note: W3 Total Cache does have support for memory-based storage options (APC, eAccelerator, etc.) instead of saving everything to the server’s hard disk, so if these options are available to you it may be advantageous to try them out.

Step 4: Testing

At this point you want to open up your website in your browser and pull up a few posts and pages to make sure things are working correctly.  If everything is coming up quickly and correctly you’ve done it, a properly cached and compressed WordPress site!  Now to test whether different parts of your site are being compressed you can use this handy Gzip Test tool to test a blog post or page URL, a Stylesheet URL, and a Javascript URL.  Make sure the Stylesheet and Javascript urls you are testing point to your website and not an external site.  You want each result of this test to say, “Webpage compressed? Yes.”  If your CSS and JS files are not testing as compressed then you will want to check out Appendix A: Scripts Gzip.

Appendix A: Scripts Gzip

If using W3 Total Cache does not result in your Javascript and CSS being served up as Gzip compressed files then you need this script. It will try it’s best to combine all your Javascript and CSS files into single files, one with all your local Javascript and one with all your local CSS. Works great, and reduces HTTP requests to boot!

  • Login to your WordPress admin interface, click Plugins on the admin menu, and then Add New
  • This will present you with the Install Plugins screen, type “scripts gzip” into the search box and click Search Plugins, and then click Install Now under the entry for Scripts Gzip
  • After Installation has completed go ahead and activate the plugin
  • Modify your theme’s footer.php file and insert <!--SCRIPTS_GZIP-JS--> just above the call to the wp_footer() function, this will cause your Javascript to load at the bottom of the document, which is recommended (CSS at the top, JS at the bottom)
  • Repeat Step 4: Testing to make sure your local CSS and JS files are being compressed

Filed Under: Web Development Tagged With: cache, compression, css, gzip, javascript, performance, speed, wordpress

  • « Previous Page
  • 1
  • 2

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • How to Permanently Remove the “Learn about this picture” Spotlight Wallpaper Icon From Your Windows Desktop
  • How to Quickly Test a Fax Machine
  • Extremely Useful Applications for Web Development and IT Tasks

Tags

automatic benchmark bigint class composer css embed escape event font function gzip helper htaccess html htmlspecialchars image increment javascript jquery list magento media mysql number observer opencart order output photo php profiling random redirect rijndael software text type ubuntu url windows windows 7 wordpress xampp xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2025 WarpConduit Computing. All Rights Reserved.