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
To create the favicon image you should follow following rules
By cropping or adding space around the image, make the image square.
Resize the image to 16 x 16 pixels.
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.
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.
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.
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.
.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'')) echo 'class="php_category"';?>>
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
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');
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
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.
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
WordPress provides the following functions to schedule the events.
wp_schedule_event(); //using this method you can schedule events.
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;
?>
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.
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');
?>
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.
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);
}
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
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
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
Normally when we are creating wordpress theme for showing the pages we code as follows