how to serve wordpress images from subdomain

creating sub domain for wordpress images is best way to increase your wordpress site speed. We given steps to, how to serve wordpress images from sub domain. Many shared hosting and wordpress bloggers and  websites are using the apache web server for hosting the wordpress sites. Apache Web server is having his own rules and behavior. By default when you open webpage of your website. That time you are making so many requests to apache web server with same domain name. That will create queue to apache web server with same domain name.

how to serve wordpress images from subdomain

For reducing the load time you should keep image file on different sub domain. Means though image subdomain you can send a parallel request to Apache web server. It will reduce the concurrent connections to web server. WordPress provides the functionality to set different domain or sub domain for images.

In this article I will show you how easily you can set the wordpress images from sub domain. First create subdomain through your control panel. Use following step for creating subdomain.

how to serve wordpress images from subdomain
how to serve wordpress images from subdomain

I recommend to create the images subdomain because images subdomain is good for SEO. Here I created the purabtech.in/files/ subdomain for my images. Then set your wordpress images path in document root setting. Normally your wordpress images are stored in wp-content/uploads directory. You can use following setting for setting the document root.

how to serve wordpress images from subdomain
how to serve wordpress images from subdomain

After creating subdomain for images and setting up the correct document root for images subdomain. Go to your wordpress admin panel. From right side panel you should go to settings -> Media panel. This page will look like as follows:

how to serve wordpress images from subdomain
how to serve wordpress images from subdomain

In “Full URL path to files” textbox put your image subdomain name and click on save changes button. Uncheck the organize my uploads into month- and year-based folder option because which is not good for SEO purpose.

After this your images will come from image subdomain but old uploaded image files will still come from older location and same domain. For changing the older images file location and domain information you should use the following steps.

Go to your Mysql databases and select the your wordpress database. You can use the phpmyadmin sql manager for this or you can use command prompt for this if you are having dedicated hosting server. If you taken shared hosting then I recommend to use PhpMyAdmin.

Use following two SQL query: (Note: You should use your images subdomain and your domain name in SQL query)


UPDATE wp_posts SET post_content = REPLACE(post_content,'http://images.purabtech.in/','http://images.purabtech.in/');

UPDATE wp_posts SET guid = REPLACE(guid,'http://images.purabtech.in/','http://images.purabtech.in/');

After this your old images files will point to images subdomain. If your images and wordpress website is old then google and other search engines already indexed your images. So We need to write the redirection rewrite rule for images in your .htaccess file. This file you will find in your Root directory of wordpress installation.

Use following line of code in your .htaccess file.


RewriteEngine On
RewriteBase /

RedirectMatch 301 ^/wp-content/uploads/(.*)$ http://images.purabtech.in/$1

Above all steps are important to change the wordpress images into images subdoamin. If you are having any issues or questions about this article. Then please write to me.

remove blog word from wordpress permalink url

Many times we need to remove the category or blog slug from wordpress URL.  We can very easily remove the blog word from wordpress blog URL. In this tutorial, We are going to show remove blog word from wordpress permalink url. this is useful when you upgraded your wordpress multisite installation.

remove blog word from wordpress permalink url

I personally used wordpress mu for long time. When wordpress 3.0 launched with multisite functionality we started using wordpress 3.0. Removing blog and category slug is very important for many clients.

I am assuming you are using wordpress 3.0 multisite installation. If that is so then you need to do following action.

First login to wordpress admin and go to Super Admin > Sites > Edit

and Scroll down to “Permalink Structure” and remove the “/blog” part. That should work.

Image is shown as like.

remove blog word from wordpress permalink url
remove blog word from wordpress permalink url

than update the option and your issue will be solved. If you are still facing issue then you need to use following code in your functions.php file. Following code is useful for those who updated wordpress mu from wordpress 3.0, other wise they can use above action.


add_filter("pre_update_option_category_base","remove_blog_slug");
add_filter("pre_update_option_tag_base","remove_blog_slug");
add_filter("pre_update_option_permalink_structure","remove_blog_slug");

/* just check if the current structure begins with /blog/ remove that and return the stripped structure */
function remove_blog_slug($tag_cat_permalink){

if(!preg_match("/^\/blog\//",$tag_cat_permalink))
return $tag_cat_permalink;

$new_permalink=preg_replace ("/^\/blog\//","/",$tag_cat_permalink );
return $new_permalink;

}

If you want advanced permalinks then I can suggest following wordpress plugin for changing the permalink

Advanced Permalinks

advanced permalink options that allow you to:

  • Have multiple permalink structures. Permalinks can be assigned to posts or ranges of posts
  • 301 redirect old permalink structures (many structures are allowed)
  • Category-specific permalinks. Posts in certain categories can be assigned a permalink structure
  • No need to have a base to the category permalink!
  • Change author permalinks
  • Enable periods in permalinks – perfect for migrating old websites

If you need more information or help then you can contact me through contact form.

how to show featured posts in wordpress homepage

For show featured posts in wordpress on home page. You can select article to show on home page. We have code snippet for show featured posts in wordpress. Showing featured post is good for seo also. Important and selected article you can show on home always. Featured post is great functionality introduced by wordpress.

show featured posts in wordpress

Some times we want to need to show featured posts in wordpress blogs on home page. You can select most popular or nice articles to show on home page. In this tutorial I will will show how you can show the featured wordpress posts on home page.

There is very simple way to show featured post on home page. First you need to create featured wordpress category and whatever post you want to show as featured post that posts select under featured post.

Then use following code:

<?php
  query_posts('category_name=featured&posts_per_page=5');
  if (have_posts()) : while (have_posts()) : the_post();
?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>

Above code you need use in index.php and single.php file. Or you can following code for showing featured wordpress post.

 <?php while ( have_posts() ) : the_post() ?>

      <?php  if(get_post_meta($post->ID, 'type', true) == "featured") {; ?>
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark">
<img src="<?php echo get_post_meta($post->ID, 'intro_thump', true); ?>" alt="Icon for Post #<?php the_ID(); ?>" />
</a></h2>
<?php  }; ?>
<div class="entry-content">

     </div><!– .entry-content –>
<?php endwhile; ?>
show featured posts in wordpress
show featured posts in wordpress

Add google maps in wordpress post

You can add the google maps in wordpress post or pages very easily. You need to just use following code in your functions.php file. Open your functions.php file from your wordpress theme folder and copy paste the following code in that file.

Add google maps in wordpress post

You can Add google maps in wordpress post or pages very easily. Open your functions.php file from your wordpress theme folder and copy our code in file. If you don’t have functions.php file in your wordpress theme folder then create functions.php file and put following code in that file.


//Google Maps adding through Shortcode
function add_googlemap_in_wordpresss_in_wordpress($atts, $content = null) {
 extract(shortcode_atts(array(
 "width" => '620',
 "height" => '430',
 "src" => ''
 ), $atts));
 return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" >';
}
add_shortcode("googlemap_in_wordpress", "add_googlemap_in_wordpresss_in_wordpress");

How to use google maps in your wordpress posts and pages.

use the following code in your posts or pages.

[googlemap_in_wordpress width="280" height="280" src="[you_url]"]
Add google maps in wordpress post
Add google maps in wordpress post

You can change the height and width as per your requirement and for url you need to use following url
http://maps.google.com/
go to above url and choose your location and right side top you will find the link option. click on that link url and you will get the link of your location. Just copy paste that url. example as follows

[googlemap_in_wordpress width="280" height="280" src="[http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=New+York,+NY,+United+States&sll=37.0625,-95.677068&sspn=47.215051,79.013672&ie=UTF8&hq=&hnear=New+York&ll=40.555548,-73.730621&spn=0.356317,0.617294&z=11&iwloc=A]"]

Above code put in your post or page. you can see the google maps in your page.

Here is list of some wordpress plugins which will help you to integrate the google map in wordpress.

how to display or embed the google map in wordpress

Twitter follower count using PHP in WordPress

you can easily show twitter follower count in your wordpress site. In this tutorial we used twitter xml api for fetching Twitter follower count using PHP. You can place the twitter count in header section or footer section or sidebar section of wordpress.

Twitter follower count using PHP in WordPress

 

Twitter follower count using PHP in WordPress
Twitter follower count using PHP in WordPress

Using following code you can print the twitter followers count.


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
$twitter_api = file_get_contents('http://twitter.com/users/show/USERNAME.xml');
$text_output = '<followers_count>'; $end = '</followers_count>';
$page = $twitter_api;
$explode_content = explode($text_output,$page);
$page = $explode_content[1];
$explode_content = explode($end,$page);
$twitter_followers = $explode_content[0];
if($twitter_followers == '') { $twitter_followers = '0'; }
echo '<div><strong>'.$twitter_followers.' </strong> Followers</div>';

?>

You just need to replace the your name instead of USERNAME.

How to use the_excerpt in WordPress

We all know what is excerpt. In wordpress using excerpt is good idea. WordPress provides the inbuild function called the_excerpt. Many people want to to show first few words on the theme front page. For that this function is very useful.

How to use the_excerpt in WordPress

How to use the_excerpt in WordPress
How to use the_excerpt in WordPress

If you do not provide an explicit excerpt to a post (in the post editor’s optional excerpt field), it will display an automatic excerpt which refers to the first 55 words of the post’s content. Also in the latter case, HTML tags and graphics are stripped from the excerpt’s content.

Important Note: the_excerpt function must be written in The Loop.
For using the excerpt tag you need to put following code in the loop.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_excerpt(); ?-->

Some times you need to put excerpt tag conditionally. In archive or category and home page you want to show only the excerpt of post then you can use following code:

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> if ( is_category() || is_archive() || is_home() ) {-->
	the_excerpt();
} else {
	the_content();
} ?-->

If you want to Control Excerpt Length using Filters use following code. To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:

function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

use the_excerpt in WordPress

Tip: You can Remove […] string using Filters.By default, excerpt more string at the end is set to ‘[…]’. To change excerpt more string using excerpt_more filter, add the following code to functions.php file in your theme:

function new_excerpt_more($more) {
	return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

If you want to make read more link after excerpt then use following code:

function new_excerpt_more($more) {
       global $post;
	return '<a href="'. get_permalink($post->ID) . '">' . 'Read the Rest...' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

set post excerpt length to limited characters in wordpress

In wordpress 3.0 limiting the excerpt is very easy. the_excerpt function is very useful and helpful in wordpress. In wordpress limiting the excerpt is very easy. With our code you can set post excerpt length to limited characters in wordpress. the_excerpt function is very useful and helpful in wordpress.

set post excerpt length to limited characters in wordpress

set post excerpt length to limited characters in wordpress
set post excerpt length to limited characters in wordpress

In many wordpress theme we used the excerpt. Many times we need to control excerpt characters as per our wordpress theme requirement. You can easily change the excerpt length using wordpress hook.

You just need to open your functions.php file from your wordpress theme folder and put following code in that.

function change_excerpt_length($length) {
    return 100;
}
add_filter('excerpt_length', 'change_excerpt_length');

This filter is used by wp_trim_excerpt() function. By default the excerpt length is set to return 55 words.

Which IDE is best for wordpress development

Question is, Which IDE is best for wordpress development, Every programmer has his own choice of IDEs But I like the NetBeans so much for PHP, Java, Ruby on Rails, javascript Development. Being Programmer I like NetBeans so much.

Which IDE is best for wordpress development

NetBeans does not have any good think for wordpress still I do development in Netbeans. I know every wordpress developers first choice is Dreamweaver. I also used Dreamweaver for so many times. I can personally say Dreamweaver is really good tool for Web Designer. If you are having advanced knowledge of dreamweaver then you can develop any site in any language.

Dreamweaver is first choice for web designers. Here in this article I am going to talk about the best IDE for wordpress development.

Adobe DreamWeaver CS5

For WordPress development Dereamweaver is really great tool. You need to watch this video.

Dreamweaver is ever made IDE for wordpress development.

Netbeans

Which IDE is best for wordpress development
Which IDE is best for wordpress development

What I like about Netbeans is that is free. every update you got that is free. WordPress made in PHP and you will great support for PHP in netbeans. What you want more.  Only think I did not like about Netbeans is that is very slow on windows and linux also.

Eclipse

Eclipse is another IDE which is very popular among the programmers. I used eclipse for years. I like that so much. Eclipse has no support for wordpress but it has good support for PHP. So I like eclipse also.

How to Optimize Your WordPress Database using plugin

When we are using the wordpress sites then we need to clean the database always. If your site is having more than 500 articles then you need to worry about server performance.

How to Optimize Your WordPress Database using plugin

Mysql load will impact your server.  Many people are suggesting to use the WP-DBManager wordpress plugin. But forgot about plugin feature. That plugin specially made for database backup and managing the tables.

If you want to optimize your wordpress database then you need to use wp-optimize wordpress plugin. I found that is only plugin is helpful for really keep optimize your wordpress database.

I used that plugin. Before using that plugin my mysql database size was 135mb. After using that wp-optimize plugin features database size was 4mb. That means my database really optimized. My sites performance was also improved.

I really liked this wordpress plugin. Thanks to Ruhani Rabin who wrote this plugin.

How to Optimize Your WordPress Database using plugin
How to Optimize Your WordPress Database using plugin

You can download this plugin from here:

http://wordpress.org/extend/plugins/wp-optimize/

Simple but effective plugin allows you to extensively clean up your WordPress database and optimize it without doing manual queries.

What is features of wp-optimize?

  • Enable/Disable trackbacks for all published post
  • Enable/Disable comments for all published post
  • Removal of stale post revisions
  • Removal of stale unapproved and spam comments
  • Removal of trashed comments
  • Removal of akismet metadata from comments
  • Removal of other stale metadata from comments
  • Mobile device friendly, now you can optimize your site on the go
  • Removal of all trackbacks and pingbacks
  • Cleaning up auto draft posts
  • Removal of transient options
  • Clear out the post trash
  • Automatic cleanup of all the integrated options (also uses retention if enabled)
  • Ability to keep selected number of weeks data when cleaning up
  • Option to add or remove link on wp admin bar.
  • Enable/Disable weekly schedules of optimization
  • Apply native WordPress MySql optimize commands on your database tables without phpMyAdmin or any manual query.
  • Display Database table statistics. Shows how much space can be optimized and how much space has been cleared.
  • Enabled for Administrators only.

Every-time you save a new post or pages, WordPress creates a revision of that post or page. If you edit a post 6 times you might have 5 copy of that post as revisions. Imagine if your post or pages are long and big. It is a huge number of bytes that’s on your MySQL overhead. Now WP-Optimize allows you to optimize and shrink your posts table by removing not necessary post revisions from the database. As example, if you have a post which is approximately 100KB data and you have 5 revisions of that post, the total space wasted is about 500KB. And if you have 100 posts similar to it, you have 50MB database space wasted.

wordpress show latest post from each category

Many people want to show wordpress show latest post from each category posts from there selected categories or all categories on home page. Here we given code snippet for this.
I this article I will show how easily you can achieve this.

wordpress show latest post from each category

Please following code in your home page which is your theme’s index.php file.

&lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt;--&gt;
$categories=get_categories($all_categories);
 foreach($categories as $category) {
 $post_args=array(
 'showposts' =--&gt; 1, // you can fetch number of articles from each category
 'category__in' =&gt; array($category-&gt;term_id),
 'caller_get_posts'=&gt;1
 );
 $posts=get_posts($post_args);
 if ($posts) {
 echo '&lt;/pre&gt;
Category: sprintf( __( &quot; href=&quot;' . get_category_link( $category-&gt;term_id ) . '&quot;&gt;name ) . '&quot; ' . '&gt;' . $category-&gt;name.'&lt;/pre&gt;
&lt;pre&gt; ';foreach($posts as $post) {&lt;/pre&gt;
&lt;pre&gt;
 setup_postdata($post); ?&gt;&lt;/pre&gt;
&lt;div&gt;

php the_title_attribute(); ?&gt;&quot; href=&quot;&lt;!--?php the_permalink() ?--&gt;&quot; rel=&quot;bookmark&quot;&gt;
 &lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt; the_title(); ?--&gt;

&lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt; the_excerpt(); ?--&gt;

&lt;/div&gt;
&lt;pre&gt;
 &lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt;--&gt;
 } // foreach($posts
 } // if ($posts
 } // foreach($categories
?--&gt;

if you want to show the posts from specific articles then use following code.

&lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt;--&gt;
$selected_categories=array(
 'include' =--&gt; '1,4,9',
 'order' =&gt; 'ASC'
 );

$categories=get_categories($selected_categories);foreach($categories as $category) {
 $post_args=array(
 'showposts' =&gt; 1, // you can fetch number of articles from each category
 'category__in' =&gt; array($category-&gt;term_id),
 'caller_get_posts'=&gt;1
 );
 $posts=get_posts($post_args);
 if ($posts) {
 echo '&lt;/pre&gt;
Category: sprintf( __( &quot; href=&quot;' . get_category_link( $category-&gt;term_id ) . '&quot;&gt;name ) . '&quot; ' . '&gt;' . $category-&gt;name.'&lt;/pre&gt;
&lt;pre&gt; ';foreach($posts as $post) {&lt;/pre&gt;
&lt;pre&gt;
 setup_postdata($post); ?&gt;&lt;/pre&gt;
&lt;div&gt;

php the_title_attribute(); ?&gt;&quot; href=&quot;&lt;!--?php the_permalink() ?--&gt;&quot; rel=&quot;bookmark&quot;&gt;
 &lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt; the_title(); ?--&gt;

&lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt; the_excerpt(); ?--&gt;

&lt;/div&gt;
&lt;pre&gt;
 &lt;!--?&lt;span class=&quot;hiddenSpellError&quot; pre=&quot;&quot; data-mce-bogus=&quot;1&quot;&gt;php&lt;/span&gt;--&gt;
 } // foreach($posts
 } // if ($posts
 } // foreach($categories
?--&gt;