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"';?>>

How to add ads end of wordpress RSS feed

If you want place ads in RSS feed at end. that is very easy with wordpress websites. We given simple code, Using our code, add ads end of wordpress RSS feed.

How to add ads end of wordpress RSS feed

How to add ads end of wordpress RSS feed
How to add ads end of wordpress RSS feed

Open your functions.php file from wordpress theme folder and use following code:

function insertAds_in_rss($content) {

$content = $content.' Your ads code goes will here';

return $content;}

add_filter('the_content_feed', 'insertAds_in_rss');

add_filter('the_excerpt_rss', 'insertAds_in_rss');

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 schedule events in wordpress

As we all know cron job can be scheduled in linux systems. So scheduling the any job in wordpress is easy because scheduling the events in wordpress is provided by wordpress itself.

How to schedule events in wordpress

How to schedule events in wordpress
How to schedule events in wordpress

WordPress provides the following functions to schedule the events.

wp_schedule_event(); //using this method you can schedule events.

You can pass following parameters to this method.

wp_schedule_event(time(), ‘hourly’, ‘your_event’);

Following params you need to pass to this method.

$timestamp
(integer) (required) The first time that you want the event to occur. This must be in a UNIX timestamp format.

Default: None

$recurrance
(string) (required) How often the event should reoccur. Valid values:

* hourly
* twicedaily
* daily

Default: None

$hook
(string) (required) The name of an action hook to execute.

Default: None

$args
(array) (optional) Arguments to pass to the hook function(s).

Default: None

You can Schedule an hourly event. Example as follows:

register_activation_hook(__FILE__, ‘my_activation’);
add_action(‘my_hourly_event’, ‘do_this_hourly’);

function my_activation() {
wp_schedule_event(time(), ‘hourly’, ‘my_hourly_event’);
}

function do_this_hourly() {
// do something every hour
}

Don’t forget to clean the scheduler on deactivation:

register_deactivation_hook(__FILE__, ‘my_deactivation’);

function my_deactivation() {
wp_clear_scheduled_hook(‘my_hourly_event’);
}

Now I am going to tell you how to extend the wp_schedule_event().
We can add the more recurrences adding following code.

function ten_minute_reccurences() {
return array(
‘ten_minute_reccurences’ => array(‘interval’ => 60*10, ‘display’ => ‘Once in Ten Mintues’),
);
}
add_filter(‘cron_schedules’, ‘ten_minute_reccurences’);

If you want check this recurrences added to wp_schedule_event or not. You need to just use following code to print recurrences

php print_r(wp_get_schedules());  ?>

I found useful following URLs.

http://codex.wordpress.org/Function_Reference/wp_schedule_event
http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules
http://codex.wordpress.org/Plugin_API

If you have PHP knowledge than you should open wp-includes/cron.php file. This file has best information and methods about scheduler.

How to customize read more for every wordpress post

So many clients had requirement about customize read more link for every post. Tutorial for, How to customize read more for every wordpress post.

So achieving this functionality in easiest way is following.

Just add following code in your functions.php file.


<?php
//The Query
query_posts('posts_per_page=1');

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();

global $post;
$thePostID = $post->ID;
$custom_read_more = get_post_meta($post->ID, 'custom_read_more', true);

if ($custom_read_more) {
add_post_meta($thePostID, 'custom_read_more', 'You need to read this article');  //custom read more value
}

endwhile;
endif;
?>
customize read more for every wordpress post
customize read more for every wordpress post

Now you are set to use the custom read more value for each post. You need to just copy paste the following code in your index.php and page.php and single.php file.

<?php $custom_read_more = get_post_meta($post->ID, 'custom_read_more', true); ?>

<?php if (!$custom_read_more) { $custommore = 'Read More &raquo;'; } ?>

<?php the_content($custom_read_more); ?>

How to add Meta box to wordpress admin post page

This article will tell you about, How to add Meta box to wordpress admin post and page.Use following code and create wordpressapi.php file and upload this file to wp-content/plugins/ folder.


<?php
/*
Plugin Name:  WordPressapi Meta Box
Plugin URI: http://images.purabtech.in/
Description: Adding the Meta box to admin panel -> post
Version: 0.0
Author: WordPressapi
Author URI: http://images.purabtech.in/
*/

function wordpressapi_meta_box() {
add_meta_box(
'wordpressapi',
'Wordpressapi Box', //Meta box title
'write_in_meta_box',
'post' // You can define here where to add the Meta box(post, page, link)
);
}

function write_in_meta_box(){
echo "Wordpressapi is writing something in admin meta box";
}

if (is_admin())
add_action('admin_menu', 'wordpressapi_meta_box');
?>
add Meta box to wordpress admin
add Meta box to wordpress admin

Go to your Plugin tab and activate the “WordPressapi Meta Box” plugin.
After activating the plugin you are able to see the Meta box on post page.

How to create or add new tables using wordpress theme

With custom professional theme you need to add the custom table in wordpress database, Using this code you can, add new tables using wordpress theme

add new tables using wordpress theme

If you want to add one more table to wordpress database you need to just use the following code.

Open the functions.php file and copy paste the code.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]


$wordpressapi_db_version = "1.0";

global $wpdb;
global $wordpressapi_db_version;

$table_name = $wpdb->prefix . "liveshoutbox";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {

$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time bigint(11) DEFAULT '0' NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url VARCHAR(55) NOT NULL,
UNIQUE KEY id (id)
);";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);

$welcome_name = "Mr. WordPress";
$welcome_text = "Congratulations, you just completed the installation!";

$insert = "INSERT INTO " . $table_name .
" (time, name, text) " .
"VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) . "')";

$results = $wpdb->query( $insert );

add_option("wordpressapi_db_version", $wordpressapi_db_version);

}

[/viral-lock]

register_activation_hook(__FILE__,'YOUR_FUNCTION_NAME');
add new tables using wordpress theme
add new tables using wordpress theme

How to exclude pages from wordpress menu without plugin

In this tutorial we will show you How to exclude pages from wordpress menu without plugin. We given simple code for adding to your theme file which will remove pages from menu.

How to exclude pages from wordpress menu without plugin

Normally when we are creating wordpress theme for showing the pages we code as follows

<?php wp_page_menu('show_home=1&amp;menu_class=page-navi&amp;sort_column=menu_order'); ?>
How to exclude pages from wordpress menu without plugin
How to exclude pages from wordpress menu without plugin

As per this code all pages will get displayed in menu. For showing selected pages check the page id.

and then use following code.

<?php 
wp_page_menu('show_home=1&amp;exclude=5,9,23&amp;menu_class=page-navi&amp;sort_column=menu_order'); 
?>

You are able to see the I added the exclude parameter in wordpress method.
Your selected page id for excluding from menu, you need to just put there with comma separated.

Put this code in your header.php file for showing the menu. You are able to exclude the pages from wordpress menu

add selected pages in wordpress menu

In this tutorial I will show you how to show the only selected pages in menu. add selected pages in wordpress menu using our code sample. which can be added.

add selected pages in wordpress menu

add selected pages in wordpress menu
add selected pages in wordpress menu

Normally when we are creating wordpress theme for showing the pages we code as follows

<?php 
wp_page_menu('show_home=1&amp;menu_class=page-navi&amp;sort_column=menu_order'); 
?>

As per this code all pages will get displayed in menu. For showing selected pages check the page id.

and then use following code.

<?php
 wp_page_menu('show_home=1&amp;include=5,9,23&amp;menu_class=page-navi&amp;sort_column=menu_order'); 
?>

You are able to see the I added the include parameter in wordpress method. Your selected page id you need to just put there with comma separated.

Put this code in your header.php file for showing the menu. Only selected pages will be shown on wordpress menu.