If you use query_post function on a theme’s homepage, you might land up messing up with the pagination function of WordPress.
Here is the quick fix to wordpress pagination (Next Previous Posts) function:
1. Add up the following line of code just BEFORE the query_post() function:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
2. Add the variable $paged to your query_post function (notice the extra variable at the end of the query post function):
query_posts('orderby=date&order=DESC&posts_per_page=5&cat=blog&paged='.$paged);
Popularity: 2% [?]
Creating a custom post types in WordPress is very simple. All you need to do is register the custom post type.
Copy the function below to your theme’s function.php file
The function below adds a custom post type “Ideas” with the same columns.
register_post_type('ideas', array(
'label' => __('Ideas'),
'singular_label' => __('Ideas'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'supports' => array('title', 'editor', 'author')
));
If you want to list the posts posted under the custom post type, you can use the query_posts function:
query_posts('post_type=ideas')
Popularity: 1% [?]
Facebook Link button is now floating on almost every website.
By default, when a user clicks on Facebook “Like” button on any of your webpage, it will post the image thumbnail, title and description from the same page.
Just in case you want to provide a custom image Thumbnail and/or custom Title, you can do it quickly by adding the following meta tags in your page header.
Click on Facebook like button below to see how it works
Popularity: 2% [?]
Quite sometime you may want to login as root to administer your Dedicated or Virtual Dedicated server. Godaddy doesn’t allow you to directly login as “root”.
You can however, easily turn on “root” user on your Godaddy server
1. Login into your Dedicated/VDS server using putty or similar software using your account username and password
2. Type the following command (without qutoes) and hit enter key “command su -”
3. You will notice that you are now logged in as root user!
Popularity: 2% [?]
Imagine you want to switch to a new dedicated server and your current website size is say 5 GB. It becomes really cumbersome to first download the entire website to your local PC and then upload it to your new server.
Thanks to Linux SCP command that you can directly copy files/folders between two servers (with SSH access, ofcourse)
This is the Linux scp command syntax to retrieve file or directory FROM a remote computer:
scp -r login name@ip-address :/path/filename .
the last period (.) tell the shell to copy the files to the current directory
This is the Linux scp command syntax to send file or directory TO a remote computer:
scp -r /path/filename login_name@ip-address : .
Popularity: 3% [?]
The Twenty Ten theme uses loop function to show posts on the homepage or category pages.
The novice users might find it difficult to work with loop.php
If you want to show the list of comments & comment form for each of the blog posts on the homepage of the blog, just add the following line of code
global $withcomments; $withcomments = 1;
just before
get_template_part( 'loop', 'index' );
Popularity: 3% [?]
echo do_shortcode('[shortcode]');
Popularity: 2% [?]
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: 8% [?]
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% [?]
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: 4% [?]