How to import a compressed mysql file .sql.gz using linux shell?

Login into your server using a shell program like putty.

Type in the following command on the command line

zcat DB_File_Name.sql.gz | mysql -u username -p Target_DB_Name

where

DB_File_Name.sql.gz = full path of the sql.gz file to be imported

username = your mysql username

Target_DB_Name = database name where you want to import the database

When you hit enter in the command line, it will prompt for password. Enter your MySQL password.

You are done!

Popularity: 19% [?]

Posted in MySQL | Leave a comment

Running WordPress Queries in Non-WordPress Pages

At times you might want to run the WordPress queries or wordpress functions in the page located outside the wordpress templates.

Thanks to wordpress for providing a very simple solution to this.

You just need to include the file called “wp-load.php” in the non-wordpress file before calling any WP functions and then you can run wordpress queries or call any wordpress function in that page.

wp-load.php is located in the root folder of your wordpress installation.

eg. if you have installed wordpress in your domains root folder, wp-load.php will be there in your public_html or httpdocs folder as applicable.
if you have installed wordpress in a folder say wp in your domain root, the wp-load.php shall be located in public_html/wp/ folder.

Include this file in your non-wordpress file using a require statement at the very beginning of the file.

require('../wp-load.php');

Popularity: 2% [?]

Posted in Wordpress, Wordpress Hacks | Leave a comment

Canonical URL solution – redirect non-www to www and index.php to your homepage

Canonical URL issue has always been a headache to the Webmasters and SEOs. But thanks to apache’s mod_rewrite which provide nice escapes for this problem

1. Rewrite all your urls WITHOUT www to WITH www

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^euttaranchal.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

2. Redirect all your index.php and index.html files to homepage or directory root

Options +FollowSymLinks
RewriteEngine on

#rewrite your index.html to homepage 
#eg:  http://www.yourdomain.com/index.html to http://www.yourdomain.com/

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.yourdomain.com/$1 [R=301,L]

#rewrite your index.php to homepage 
#eg: http://www.yourdomain.com/index.php to http://www.yourdomain.com/
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]

** you can do this for default.html or other pages too depending on your default page name.

Popularity: 5% [?]

Posted in SEO, URL Rewriting, Webmaster Issues | Leave a comment

WordPress asking for FTP username/password while trying to install plugin from admin panel

This is annoying if WordPress asks for FTP username/password everytime you try to install or update plugin from admin panel.

Here is the quick hack to this.

1. Open the wp-config.php file (this will be located in the root of your wordpress installation)

2. Add the following line of code just after define(‘NONCE_KEY’, ‘put your unique phrase here’);

/* FTP login settings */
define('FTP_HOST', 'localhost');
define('FTP_USER', 'yourftpusername');
define('FTP_PASS', 'yourftppassword');

Note: Be sure to replace yourftpusername to your website’s FTP user name and yourftppassword to your website’s FTP password.

3. Upload the updated file. It works!

Popularity: 21% [?]

Posted in Wordpress, Wordpress Hacks | 1 Comment

Custom User Registration Plugins for WordPress

I have been trying hard to find an easy way out to add custom registration field to the WordPress default registration form.

I recommend the following wordpress plugin to customize, add custom fields, manage user registration, moderate user registration and edit the default email sent to the new registered users.

1. Cimy User Extra Fields
This plugin gives you the power to add custom fields to your wordpress registration form. You also get the choice to add different data types like text box, select box, radio button, text area etc with quite a few validation options.

Cimy User Extra Fields also unleashes the hidden registration fields that come with wordpress default registration form.

Download

2. Approve New Users

You can moderate New User Registration with this plugin. It adds another option “Approve New Users” under “Users” settings menu.

Download

3. New User Email Setup

New User Email Setup plugin lets you customize the default email sent to the new users upon registration. You can customize the email text, sender name, sender email and subject too. What’s more, you can even send HTML email!

Download

Popularity: 99% [?]

Posted in Wordpress | Tagged | 1 Comment

WordPress Solutions: Add New Custom Field Not Working

If you are having an issue adding a new custom fields in your wordpress blog, here is the possible solution.

Problem: Add New Custom Field Doesn’t Work at all. When you click on “Add Custom Field” nothing happens!

Solution: Refer to your Theme’s Function file (functions.php) located in your theme directory. Remove any blank lines from the file functions.php

It works!

Popularity: 22% [?]

Posted in General | Leave a comment

Thumbnail for Excerpts : Hack for WordPress 2.8+

I was stucked with Thumbnail for Excerpt plugin behaving unexpectedly with WordPress 2.8.2

Thank you Cory for sharing the plugin hack to make it work.

Bug: The Thumbnail for Excerpt plugin showing the same thumbnail image with all the posts (with WordPress 2.8.2+)

Solution: Edit the plugin in plugin editor. Replace lines 28 & 29 with this:

global $wp_query, $wpdb, $post;
$id = $post->ID;

The actual lines of code look like this

global $wp_query, $wpdb;
$id = $wp_query->post->ID;

Replace these lines with

global $wp_query, $wpdb, $post;
$id = $post->ID;

Popularity: 28% [?]

Posted in Wordpress | Tagged , | 1 Comment

Application letter petroleum engineer

I was stucked finding an easy solution to highlight the background of the current (active) page in wordpress. The solution is however too simple. Just add the following CSS code in your stylesheet (style.css)

#menu_id li.current_page_item a{
    background:#2E8DE6;
}

Note: Be sure to replace #menu_id with the id of your navigation bar. In this case, the list of my pages is contained in a div with id menu_id

highlight-active-page

Popularity: 24% [?]

Posted in General | Leave a comment

Yamidoo Theme Featured Content Image Slider Fix

Yamidoo Magazine Theme is one of the popular wordpress theme to give your blog a professional and fresh look. However, one of the common problem encoutered by Yamidoo theme users is that the Featured Content Gallery doesn’t slide automatically.

A simple tweak below can fix this bug and make the Featured Content Gallery on the Yamidoo Theme sliding

Open the Main Index File: /wp-content/themes/yamidoo/index.php
(assuming that you have uploaded the theme under yamidoo folder)

Search for these 2 lines (somewhere near line number 36 on index.php file):



Right BEFORE these two lines, add this line:


If you want to control the autoslider, in your header.php file, there is one such line:
autorotateconfig: [1000, 0]

The first value (default: 1000) controls the speed (in miliseconds). 1000 = 1 second.
The second value (default: 0) controls how many cycles the slider should have. If you leave it 0 – it will autoslide over and over again, an infinite amount of times.

Popularity: 38% [?]

Posted in Wordpress | Tagged , | Leave a comment

Custom Read More link for WordPress

The default “read more” link for the wordpress that comes with the_excerpt function shows […] after every post listing WITHOUT a hyperlink to the post.  To make the_excerpt function more useful, you can add a custom read more link which will replace […]

It require a small tweak in wp_trim_excerpt function.

Open your wordpress file /wp-includes/formatting.php

Go to line number 1482. The wp_trim_excerpt function would read like this

BEFORE

function wp_trim_excerpt($text) {
if ( '' == $text ) {
$text = get_the_content('');

$text = strip_shortcodes( $text );

$text = apply_filters(‘the_content’, $text);
$text = str_replace(‘]]>’, ‘]]>’, $text);
$text = strip_tags($text);
$excerpt_length = apply_filters(‘excerpt_length’, 55);
$words = explode(‘ ‘, $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, […]);
$text = implode(‘ ‘, $words);
}
}
return $text;
}

AFTER (refer to the modified text in red)

function wp_trim_excerpt($text) {
if ( ” == $text ) {
$text = get_the_content(”);
$read_link='<a href=”‘. get_permalink().'”>’;
$end_read_link=”</a>”;

$text = strip_shortcodes( $text );

$text = apply_filters(‘the_content’, $text);
$text = str_replace(‘]]>’, ‘]]&gt;’, $text);
$text = strip_tags($text);
$excerpt_length = apply_filters(‘excerpt_length’, 55);
$words = explode(‘ ‘, $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, ‘…’.$read_link.'[read more]’.$end_read_link);
$text = implode(‘ ‘, $words);
}
}
return $text;
}

Cheers…you are done!

Popularity: 40% [?]

Posted in Wordpress | Tagged | Leave a comment