Changing WordPress Site URL using raw MySQL Query

At times, you may want to migrate a wordpress installation to another domain. At that point of time, you need to change the website url in the wordpress database to point to the new website url.

1. Change the option values in wp_options table

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-website.com', 'http://www.new-website.com') WHERE option_name = 'home' OR option_name = 'siteurl';

2. Change the guid value (post url) in wp_posts table

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-website.com', 'http://www.new-website.com');

3. Look up and replace the url in post content in wp_posts table

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-website.com', 'http://www.new-website.com');
Posted in Wordpress, Wordpress Hacks | Leave a comment

WordPress: WP Query with Custom Fields

$args = 
	array(
		'posts_per_page' => -1,
		'meta_key' => 'city',
		'orderby' => 'meta_value',
		'order' => 'ASC',

		'meta_query' => array(
			array(
					'key' => 'destination_type',
					'value' => 'city, state',
					'compare' => 'IN'
				),
			
			array(
					'key' => 'country',
					'value' => $country,
					'compare' => '='
				),
			
			array(
					'key' => 'best_time',
					'value' => $month,
					'compare' => 'LIKE'
				),
			
			array(
					'key' => 'type',
					'value' => $type,
					'compare' => 'LIKE'
				)
			)
		);

		$the_query = new WP_Query( $args );

		if ( $the_query -> have_posts() ) :
		echo '
'; while ( $the_query->have_posts() ) : $the_query->the_post(); echo ''; endwhile; echo '
endif; wp_reset_query(); wp_reset_postdata();
Posted in Wordpress | Leave a comment

Themed Login & Register Page for WordPress

WordPress is a great CMS and has huge customization abilities.

Adding to the list is the “Theme My Login” plugin through which you can have themed “Login”, “Lost Password” and “Register” page. Just install and activate the plugin and you are done!

Other Features:

  • Includes a customizable widget to login anywhere from your wordpress site
  • Redirect users upon log in and log out based upon their role
  • Show gravatar to users who are logged in
  • Assign custom links to users who are logged in based on their role
  • Customize user emails for registration and/or password recovery
  • Send user emails in HTML format
  • Allow users to set their own password upon registration
  • Require users to be approved or confirm e-mail address upon registration
  • Theme user profiles

Download Theme My Login plugin

 Related Plugin

At times you will want to allow your users to post an article on your website from the frontend. “WP User Frontend” is one such plugin which allows you to customize the entire user experience and seamlessly integrate the frontend and backend.

Features

  • User can create a new post and edit from frontend
  • They can view their page in the custom dashboard
  • Users can edit their profile
  • Administrator can restrict any user level to access the wordpress backend (/wp-admin)
  • New posts status, submitted by users are configurable via admin panel. i.e. Published, Draft, Pending
  • Admin can configure to receive notification mail when the users creates a new post.
  • Configurable options if the user can edit or delete their posts.
  • Users can upload attachments from the frontend
  • Post featured image can be set
  • Admins can manage their users from frontend
  • Pay per post or subscription on posting is possible

Download WP User FrontEnd plugin

Posted in Wordpress | Leave a comment

The Power Backup. Is it really?

For a business like mine which greatly depends on Internet and IT, the key backbone to the business infrastructure is “power backup.” Can you imagine seeing hundreds of your employee sitting idle waiting for their PCs to boot up again? When it comes to power backup for IT systems, the most effective business solution is online UPS.

Selecting an Online UPS was not an easy task for me and a lot of research and studies landed me at 3EM Power Technologies, a Delhi based manufacturer of Online UPS. Their sales person Mr Amit Saxena was very prompt to visit our office and guided us to sum up our requirements. After evaluation of my power requirements, I ordered a 5KVA online ups with 12x45AH batteries from 3EM Power.

The show was running fine until one day I realized that the UPS backup was not at par which I expected.  As per the calculations and my UPS configuration (and my purchase order), a 5 KVA UPS should be able to take a load of 4 KW for atleast 2 hours. However, my UPS is now giving me a backup of barely 1 hour that too with just 2KVA load?

I called up Mr Amit Saxena and he was polite enough to register a complaint with their customer care department. When I didn’t hear anything from the customer care, I made a followup call. The customer service executive didn’t sound any professional and was listening to my complaint just like a “sarkari babu”. Anyhow, he assured me that the service engineer would visit the place the next day, which of course didn’t. I again made a follow up call at the customer care and got the same cold assurance. The next day, I called up Mr Amit, and was totally disgusted when he told me that the service engineer has already attended my complaint which he sure knew didn’t. He then tried to give me false assurance that he would look into it and the problem would be attended at the earliest.

Now, it has been 2 weeks since I raised the complaint but no one is bothered to attend. What can I do as a customer? My customer rights do allow me to knock the doors of Consumer Court if I can’t find any other alternative to get job done. That would be long battle then. The reason I am sharing my “Power” story online is to alert the other users to be very careful choosing their “Power” backup system.

I am not surprised with the quality of post sales service and support in India, neither it is my first such experience. But being into customer service business I feel concerned for my customers and expect the same as a customer from my service providers.

 

Posted in Misc | Leave a comment

URL Rewriting – An Introduction

1. Rewriting all URLs ENDING with “my-string” and sending it to my-file.php

$ indicates end of string.
i.e. match any URI ending with string preceding $

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /my-string$
RewriteRule ^([_a-zA-Z0-9-]+)$ /my-file.php?string=$1 [L,NC]

2. Rewriting all URLs ENDING with “my-string” OR “another-string” and sending it to my-file.php

RewriteCond %{REQUEST_URI} /my-string$| /another-string$
RewriteRule ^([_a-zA-Z0-9-]+)$ /my-file.php?string=$1 [L,NC]

3. Rewriting all URLs matching this pattern
my-string/(any-alpha-numeric-chars)/(any-alpha-numeric-chars)/

RewriteCond %{REQUEST_URI} /event/([_a-zA-Z0-9-]+)/([_a-zA-Z0-9-]+)$
RewriteRule ^([_a-zA-Z0-9-]+)$ /my-file.php?string1=$1&string2=$2&string3=$3 [L,NC]

Posted in URL Rewriting | Leave a comment