how to add a favicon to your wordpress site

In this tutorial we will show, how to add a favicon to your wordpress site, If you want to add the favicon image in your wordpress website that is really easy.

First use any photo editing tool like photoshop or gimp for creating the favicon image.

how to add a favicon to your wordpress site

how to add a favicon to your wordpress site
how to add a favicon to your wordpress site

To create the favicon image you should follow following rules

  1. By cropping or adding space around the image, make the image square.
  2. Resize the image to 16 x 16 pixels.
  3. Save the file as favicon.ico

Open your active wordpress theme and put favicon.ico image file in that folder or using ftp client you can put favicon.ico file in theme folder. After coping the favicon image file in theme folder. Open your header.php file from wordpress theme folder. and Put following code in that file.

 

 <link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" type="image/x-icon" />

Dont forget to put above code under head tag. Now your are set and changed the favicon from your wordpress site. To see the new favicon image you should clear your browser cache.

 

change background for specific page and category in wordpress

WordPress tutorial, We will show how to change background for specific page and category in wordpress theme. achieve using conditional tags.

change background for specific page and category in wordpress

Many times clients demands for different background color or different images as a background. We can very easily achieve this using wordpress conditional tags.

change background for specific page and category in wordpress
change background for specific page and category in wordpress

You can use following code in your page.php or category.php file which is present in wordpress theme. If you want to change the background for specific page then open page.php file from theme folder.


<body <?php if(is_page('contact us'))&nbsp; echo 'class="contact_us"';?>>

Use following css code in your style.css file


.contact_us{

.background-color:#ccc;

}

.php_category{

.background-color:#181818;

}

If you want to use different background for your category then use following code.



<body <?php if(is_category('php''))&nbsp; echo  'class="php_category"';?>>

change image of on MouseOver Event using JavaScript

Using only javascript and CSS you can easily achieve mouseover effect. In article we given sample code for change image of on MouseOver Event in your site.

change image of on MouseOver Event using JavaScript or CSS

change image of on MouseOver Event using JavaScript or CSS
change image of on MouseOver Event using JavaScript or CSS

If you want to change the image on rollover or mouseover event. This is very old technique. You can achieve this using CSS or javascript. I given the simple and powerful code javascript mouse event. I tested this code. It works on all the browsers.

With CSS you can use the following code:


.yourimage { background-image: url('firstImage.jpeg'); }
.yourimage:hover { background-image: url('secondImage.jpeg'); }

<div class=”yourimage” style=”height:100px;width:100px;min-height:100px;min-width:100px;”></div>

I am using the yourimage class for div element.

With javascript you can use following code

<div>
<img src="firstimage.jpeg" onmouseover="this.src='secondimage.jpeg'" onmouseout="this.src='firstimage.jpeg'"/>

If you are using the Jquery then use following code:

<style>
.imagediv{background-image:firstimage.jpg}
<div class="imagediv"/>

 $(document).ready(function () {
            $('div.imagediv').mouseover(function () {
                $(this).css(background-image", "url('secondimage.jpg')");
            });
        });

How to block your rss feed in wordpress website

In that situation you need to use following techniques. We given tricks, techniques and code for block your rss feed in wordpress website. Many people does not want to show their websites need to be cached or indexed by search engine. In that situation you need to use following techniques.

How to block your rss feed in wordpress website

How to block your rss feed in wordpress website
How to block your rss feed in wordpress website

First create the robots.txt file and put following code in that file.

User-agent: *

Disallow: /

You need to open functions.php file for disabling the rss feed from your website.
Put following code in that file.

function disable_rss_feed() {
    wp_die( __('No Rss feed are available,please visit our <a href="'. get_bloginfo('url') .'">website</a>!') );
}

add_action('do_feed', 'disable_rss_feed', 1);
add_action('do_feed_rdf', 'disable_rss_feed', 1);
add_action('do_feed_rss', 'disable_rss_feed', 1);
add_action('do_feed_rss2', 'disable_rss_feed', 1);
add_action('do_feed_atom', 'disable_rss_feed', 1);

How to use word wrap with css

Many times we need to do word wrap using languages. I recommend use css for word wrapping. In this article, we explained about How to use word wrap with css

How to use word wrap with css

You can force long (unbroken) text to wrap in a new line by specifying break-word with the word-wrap property.
This is a problem with CSS layouts that use floated divs.

use word wrap with css
use word wrap with css

Use following code for fix the word wrap with all divs.

div { word-wrap: break-word }

instead of this we always use following css code:

overflow:hidden;

But this is not good practice. Use word-wrap css property.
Word-wrap is supported in IE 5.5+, Firefox 3.5+, and WebKit browsers such as Chrome and Safari.

how to pull sticky post from wordpress

From wordpress 2.7 version wordpress introduced the new feature called sticky post. Sticky post will give you ability to show the most popular or your favorite post always top of the posts.

how to pull sticky post from wordpress

how to pull sticky post from wordpress
how to pull sticky post from wordpress

Sticky post feature is very nice for wordpress theme developer. Here I will show you how to create sticky post in wordpress.

When you are creating the new post or editing the wordpress post you can choose the stick ths post option. This is very simple way to create the sticky post.

If you want to some good styling to post then use following css code. Just open your style.css file from your template.


.sticky {
 background: #ccc;
 border: 5px solid blue;
}

If you want to show the sticky post in any specific page then use following code.


is_page('sticky page') {
query_posts(array('post__in'=>get_option('sticky_posts')));
}
how to pull sticky post from wordpress
how to pull sticky post from wordpress

how to change date format in php

We will show, how to change date format in php code. If you want to change the date format and save into mysql database. You can use our php code or script. You can use following php functions.

how to change date format in php

Let say you are getting date in yyyy-mm-dd format and you want to convert that into dd-mm-yyyy format and save into database. so you can use following function.

$timestamp = strtotime(your date variable);
$new_date = date('d-m-Y', $timestamp);

// or use can following code

$new_date = date('d-m-Y', strtotime(your date variable));

// or use can following code

strftime ($time, '%d %m %Y')
how to change date format in php
how to change date format in php

how to use robots.txt file in wordpress

Many person does not know importance of robots.txt file and how to use robots.txt file in wordpress. robots.txt file is important as per search engine.  The robots.txt file is very important as per search engine and SEO prospective.

how to use robots.txt file in wordpress

how to use robots.txt file in wordpress
how to use robots.txt file in wordpress

What is robots.txt file?

Robots.txt is a text (not html) file you put on your site to tell search robots which pages you would like them not to visit. Robots.txt is by no means mandatory for search engines but generally search engines obey what they are asked not to do.

In wordpress you should put robots.txt file. you can use following code in robots.txt file and put that file under your ROOT directory( wordpress main folder)

User-agent: *
Allow: /
Disallow: /*?s=
Disallow: /wp-admin/*
Disallow: /wp-content/*
Disallow: /wp-includes/*
Disallow: /wp-content/cache
Disallow: /wp-content/themes/*<code></code>
Disallow: /wp-content/plugins/*

Important Note: if you are using the QA or testing enviourment then put following lines in your theme header.php file. You can put the domain name condition also.

<?php
if($SERVER)['HTTP_HOST']=='Testing domain name') {
?>

<?php } ?>

You should not disallow the images and comments also because that is more important for SEO purpose. I recommend to use always good permalink structure for your wordpress installation.

how to register multiple sidebar in wordpress

Many wordpress developers and PHP developers who are new in to wordpress development. They really searching for how to add a dynamic or multiple side in wordpress theme. many sidebar or widget are very important to add in any wordpress theme for seo purpose also so you can add the widgets using our code sample.

register multiple sidebar in wordpress

Many wordpress developers got requirement to add separate sidebar for each page or any specific page and that sidebar need to be controlled by wordpress admin.

In this tutorial I will show you how to simply add the multiple or dynamic sidebar to wordpress theme. I really think creating the or putting separate css and options in  the sidebar and admin has no control over the sidebar.

Just use my code to create the multiple sidebar in wordpress theme. This following function is provided by wordpress api only. Open your functions.php file from your wordpress theme folder


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
 if(function_exists('register_sidebar'))
 register_sidebar(array(
 'name' => 'Home Page', // The sidebar name you can choose as per your choice to register
 'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
 'after_widget' => 'CLOSE THE DIV',
 'before_title' => '<h2>',
 'after_title' => '</h2>',
 ));
?>

This is sample code for multiple pages your can use following code:


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
     // Home Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Home Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Blog Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Blog Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Contact us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Contact Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // About us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'About us',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));

?>

Here is Big question, How can you call the different sidebars and manage it. Go to wordpress admin and you will find and four side bars present in widgets sections as per this code. You can just drag and drop the widgets as your choice.

Open your sidebar.php file put following code in that file.

<?php
is_page('Home Page') {
     if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Page')) :
     endif;
}
?>
how to register multiple sidebar in wordpress
how to register multiple sidebar in wordpress

You can use the following type of code in your sidebar.php file as per your condition. If you have any issues get back to me.

how to remove blog or category word from wordpress URL

Many times wordpress developer got requirement to remove the blog or category word from wordpress url. Code for remove blog or category word from wordpress.

how to remove blog or category word from wordpress URL

Many people and wordpress developer want to remove the blog or category wordpress from URL. This is really good for seo also. Many times wordpress developer got requirement to remove the blog or category word from wordpress url.

how to remove blog or category word from wordpress URL
how to remove blog or category word from wordpress URL

In this tutorial I will let you know how can you easily achieve this requirement. There is two-way to achieve this requirement. You can use the .htaccess file for fulfill this requirement.

Note: Apache mod_rewrite rule is must enable to with your Apache web server.

Open your .htaccess file which is present in your root folder of web hosting server. If not then create this file put it.

You can use the permanent redirect rewrite apache rule to achieve this. open your .htaccess file put following lines in that file


RewriteEngine On
RewriteBase /

#This rewrite rule we added for removing the category wordpress from URL
RewriteRule ^category/(.+)$ http://www.purabtech.in/files/$1 [R=301,L]

#This rewrite rule we added for removing the blog word wordpress from URL

RewriteRule ^blog/(.+)$ http://www.purabtech.in/files/$1 [R=301,L]

You can achieve this by changing in the code also. Use the following code do this changes. Open your theme folder and functions.php file and put following code in that file.


function remove_blog_word($without_blog_word_permalink)
{

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

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

}

function remove_category_word($without_category_word_permalink)
 {

 if(!preg_match("/^\/category\//",$without_category_word_permalink))
 return $without_blog_word_permalink;

 $new_permalink=preg_replace  ("/^\/category\//","/",$without_category_word_permalink );
 return $new_permalink;

 }

add_filter("pre_update_option_permalink_structure","remove_blog_word");

add_filter("pre_update_option_permalink_structure","remove_category_word");

Just put above lines in your functions.php file and that will solve your issue.