Add custom background image support to wordpress

From wordpress 3.0, added new function to control the background image. For your theme if you want to add custom background image support to wordpress theme. From wordpress 3.0 release wordpress added new function to control the background color and image. For your theme if you want to add the background functionality then you need to very simple code in your functions.php file which you find in your wordpress theme folder.

Add custom background image support to wordpress

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


add_custom_background();

For enabling the background for theme you need to open header.php file and just copy paste following code in the file.

<body class="<?php body_class() ?>">

For changing the background login to wordpress admin panel and goto appearance tab and click on background tab. From here you can able to change to background image or color.

Add custom background image support to wordpress
Add custom background image support to wordpress

how to create menu in wordpress themes

From wordpress 3.0 release wordpress launched the custom navigation Menu in wordpress admin panel. wordpress tutorial for, how to create menu in wordpress themes. Through drag and drop you can manage the menus. Using this menus are very easy for users.

how to create menu in wordpress themes

how to create menu in wordpress themes
how to create menu in wordpress themes

You can check wordpress admin section for managing the menus in wordpress theme.

In this article I will show you how to enable Custom menu for your wordpress theme.

If you want to create the one menu in wordpress theme then just open the functions.php file and put following code in that file.


add_theme_support( 'menus' );

If you want to create or use the multiple menus in wordpress theme then just open the functions.php file and put following code in that file.


add_action( 'init', 'register_my_menus' );

function register_my_menus() {
 register_nav_menus(
 array(
 'primary-menu' => __( 'Main Menu' ),
 'secondary-menu' => __( 'Top Menu' ),
 'tertiary-menu' => __( 'Footer Menu' )
 )
 );
}

After this adding code in functions.php file you need to open the header.php and footer.php file.

For single menu you need to add following code in header.php file.


<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?>

For multiple menu you need to add following code in header.php or footer.php file

# Following code for Top Menu


wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'sort_column' => 'menu_order', 'container_class' => 'nav' ) );

#Following code for Main Menu


&lt;?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'sort_column' => 'menu_order', 'container_class' => 'nav' ) ); ?>

#Following code for Footer Menu


&lt;?php wp_nav_menu( array( 'theme_location' => 'tertiary-menu' ) ); ?>

Above code will give you the more control over the wordpress theme. If you have any doubts or questions then please do write to me.

mysql sleep processes issue solved

I faced the sleep query issue sometimes.  Many times that kills the server. When ever you are using dedicated virtual hosting server that time you need to me very careful how you are setting up the apache and mysql. we solved mysql sleep processes issue

mysql sleep processes issue solved

mysql sleep processes issue solved
mysql sleep processes issue solved

I found some major reasons for mysql sleep processes. Here I am giving some reasons:

[viral-lock message=”Reasons and Solution 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.”]

1. apache requests increase
2. mysql queries increase
3. mysql slow queries increase
4. apache connections start to wait on slow mysql queries
5. apache connections take longer to close
6. more apache connections are opened
7. with each apache request a new sleeping mysql connection is made
8. mysql & apache reach max_connections
9. server slows to a crawl

[/viral-lock]

Using linux top command you can check the load average and which process is taking so much memory of your server. If you saw mysqld is taking much memory of server then you should check using following mysql commands:

> show full processlist;

using this command you can check the mysql processes. Which sql queries being fired on mysql server. If you found so much sleep processes then you should check your mysql variables and settings. If so much mysql queries being fired on specific table then you should change the table storage engine type.

Using following command you can change the storage engine type.
> ALTER TABLE tablename ENGINE = MYISAM;

MYISAM storage engine type is faster then inodb. you can create the mediator tables also for big size table to handing a load of table.

Then major change for solving the issue of sleep processes is, you should change the wait_timeout variable. Default value is 2800 seconds.

mysql> show variables;

you can change the setting using following  mysql command. Best value is 60 second need to be set for wait timeout.
mysql> show variables like ‘wait_timeout’;

mysql> set global wait_timeout=60;

mysql>show variables like ‘wait_timeout’;

After doing above changes you can check the mysql processlist. If you are still facing issues with mysql then please write to me.

How to create mysql logs for specific queries

As a developers need to check the mysql logs. Many times for any request how many mysql queries are running or executed we need to know.

How to create mysql logs for specific queries.

 

How to create mysql logs for specific queries
How to create mysql logs for specific queries

In this tutorial I will show you how to created mysql log file for checking the SELECT, UPDATE, DELETE or any types of mysql queries.

If you are using the linux then use the my.cnf file which will be located in etc folder. If you are using the windows then use the my.ini file. That file you will find in following location in case of wamp server.

c:\wamp\bin\mysql\mysql5.0.45\my.ini

I am using the Linux so here I am giving that example.  use following command.

[root@siwank-pc mysql]# mkdir /var/log/mysql
[root@siwank-pc mysql]# chown mysql:mysql /var/log/mysql

[root@siwank-pc mysql]# vim /etc/my.cnf

[mysqld]
log = /var/log/mysql/mysqld.log //This log file will give you the full mysql access log

log-error=/var/log/mysql/mysqld-error.log // this log file will give you the error log of mysql

log-slow-queries=/var/log/mysql/log-slow-queries.log // this log file will give you the slow queries log

If you need the more information about mysql logs then write to me.

WordPress changed the statistic graph

Today when I logged to my wordpress blog account and looked at dashboard, I saw the new changed statistic graph.
The new statistic graph is looking really very cool. New graph version is better for those who are visually improved so nicely.

WordPress changed the statistic graph

For wordpress blogger and website users this news is really great.

Seeing this graph I must say you will miss having the grand total of both syndicated and on-site views for an entry.

As we know we need to updgrade the “WordPress.com Stats” wordpress plugin to see the updated stats in your hosted wordpress blogs.
You can download or update the wordpress stat plugin using following URL
http://wordpress.org/extend/plugins/stats/

Wordpress changed the statistic graph
WordPress changed the statistic graph

What wordpress is saying about changed Stat in Twitter.
Sexy Stats: http://wp.me/pf2B5-1n9

As per wordpress:
Each module can be opened and closed, moved, or hidden completely. If you don’t want to see a module, minimize it with one click or use the Screen Options to keep it out of sight. Customize everything and view stats the way you want to.

As you hover over each bar in the chart it changes color and displays a tooltip, giving you more information about the data. If the chart is showing data by day, Saturdays and Sundays have a light gray background to make it easier to see weekly patterns. Under the chart you’ll notice a new area, called “fortune cookies,” where we’ll highlight key stats.

During the redesign we went with bar charts because the end of one day and the beginning of another shouldn’t be connected. Each day starts at zero and we think bar charts work much better for this type of data. We hope you’ll agree once you get used to the change.

In this first phase of the stats redesign we’ve focused on the main page. This will allow us to collect feedback from you so we can tweak everything as we go. We’ve only mentioned a few of the highlights here, so take your stats for a drive around town to get used to the feel. Let us know what you like and what you might change. As we gather feedback we’ll apply a bit of sexy to the other stat pages.

Windows or MSN Space is migrating to wordpress.com

Few time ago wordpress just announced the partnership with  Microsoft. Microsoft is saying “WordPress as the new default blogging platform on Windows Live Spaces!” WordPress as the new default blogging platform on Windows Live Spaces!”

Windows or MSN Space is migrating to wordpress.com

Windows or MSN Space is migrating to wordpress.com
Windows or MSN Space is migrating to wordpress.com

Microsoft is saying “Over the last few weeks, we’ve spent a good bit of time talking about our approach to partnering with the web, and as part of that, how we’re deeply integrating with the leading consumer services that you find most valuable. Earlier today, I had the opportunity to get on stage at TechCrunch Disrupt, and with Toni Schneider, CEO of Automattic (the parent company of WordPress.com), announce an exciting partnership between our companies.”

Using this step more than 30 million users of windows space will migrate to wordpress.com.

In detail Matt is also written in his article.

MSN Spaces Closing, becomes WP.com

As we looked at how we brought Windows Live and WordPress.com together, there were three big things we wanted to deliver:

  • Giving existing Windows Live Spaces customers an easy upgrade of their blogging experience to WordPress.com
  • Letting anyone connect their WordPress.com blog to Messenger so their Messenger friends are updated when they publish a new post on WordPress.com
  • Allowing Windows Live customers to easily create new blogs on WordPress.com
Windows or MSN Space is migrating to wordpress.com
Windows or MSN Space is migrating to wordpress.com

For detail information for windows space user can use the following article for checking this further information about migrating the blog to wordpress.com

WordPress.com and Windows Live partnering together and providing an upgrade for 30 million Windows Live Spaces customers

WordPress.com is welcoming all the windows and live space users through Twitter. WordPress.com written the following tweet in Tweeter.

Welcome Windows Live Spaces Bloggers to WordPress.com! http://wp.me/pf2B5-1lU

Videos of Matt Mullenweg – WordPress founder

We all know who is Matthew Charles Mullenweg is. He dont need any introduction. Many times users, clients and developers are very interested to see what Matt is saying about wordpress and technology.

Videos of Matt Mullenweg – WordPress founder

 

In this article I am going to give you some videos of Matt which published in 2010.

Matt Mullenweg says Hi to Me!

wordcamp 2010 jerusalem q&a with Matt Mullenweg

Matt Mullenweg keynote – WordCamp Houston

Matt Mullenweg at WordCamp Houston

Matt Mullenweg and Mike Little : Cardiff July 2009.

Matt Mullenweg says hello to WordCamp Malaysia 2010 Part 1

You Are the Pride: Matt Mullenweg

WordPress creator Matt Mullenweg discusses his early days as a student at the University of Houston, and his passion for helping people find their …

WordPress Founder Matt Mullenweg

An interview with Matt Mullenweg, conducted at WordCamp SF 2010.

Matt Mullenweg talks about “Twenty Ten” for WordPress 3.0

An excerpt from Matt’s state of the word address on WordCamp San Francisco 2010

Matt Mullenweg, Founder Word Press

May 1, 2010 Matt at SF Word Camp sf.wordcamp.org

how to find out cpu and disk usage in linux

When you are running any script on server or running any application you want to know how much memory or disk uses is happened by application.

how to find out cpu and disk usage in linux

how to find out cpu and disk usage in linux
how to find out cpu and disk usage in linux

When you are doing load testing this time this kind of applications are very useful to check the server status. Create file name CPU-Disk.sh and put following content in that.

#!/bin/sh

# Change this as needed

OUTPUT_FILE=file.txt

# Initially delete old output file if needed.

/bin/rm -f $OUTPUT_FILE

while [ 1 -eq 1 ]; do

date >> $OUTPUT_FILE

echo "------------------------" >> $OUTPUT_FILE

cat /proc/meminfo >> $OUTPUT_FILE

echo "------------------------" >> $OUTPUT_FILE

df -k >> $OUTPUT_FILE

echo "------------------------" >> $OUTPUT_FILE

top -b -i -n 1 >> $OUTPUT_FILE

# Record terminator. Add more === if needed :)

echo "========================" >> $OUTPUT_FILE

sleep 60

done

This command is useful to create the sh file executable in linux

#chmod +x /YOURPATH/CPU-Disk.sh

when you need to check the server status you need to run the this file using this command

#CPU-Disk

how to use rdesktop command in linux

You can use the windows machine from linux OS. Using rdesktop program this is possible. Here is Linux tutorial, how to use rdesktop command in linux. Windows and Linux have made inroads into organizations around the world.

how to use rdesktop command in linux

 

how to use rdesktop command in linux
how to use rdesktop command in linux

Rdesktop is a Linux implementation of Remote Display Protocol (RDP). Windows uses RDP to connect to other Windows computers via Terminal Services. With rdesktop, you can open a remote control session on a Windows NT/2000/XP machine from a Linux box.

On fedora OS rdesktop utility is already installed. If that utility is not installed then use following command to install rdesktop
#yum install rdesktop

Use following command to use the remote desktop

[siwan@siwank-pc ~]$ rdesktop 192.168.2.45

For Full screen Use following Command.

[siwan@siwank-pc ~]$ rdesktop -f 192.168.2.45

How to minumize the rdesktop?

Use the following command. If you are in full screen mode then press ctrl + alt + enter button to back again.

This is very nice utility for Linux and Windows users. Who need to work on both the OS on same time.

Fadein and Fadeout effect through javascript example

 

Many times we need the fadein and fadeout effect using javascript. Javascript tutorial for, Fadein and Fadeout effect through javascript example.  But many developers go for jquery for using simple fadein and fadeout effect

Fadein and Fadeout effect through javascript example

Fadein and Fadeout effect through javascript example
Fadein and Fadeout effect through javascript example

I suggest not to Jquery and Use following code for effect.  This is very minimal code and you can very easily customize the CSS and javascript as per your requirement.

<html>
 <head>

 <style type="text/css">

 .popup {
 border: solid 1px #333;
 font-family: Tahoma;
 font-size: 12px;
 display: none;
 position: absolute;
 width: 300px;
 z-index: 60;
 }

 .popuptitle {
 background: blue;
 color: white;
 font-weight: bold;
 height: 15px;
 padding: 5px;
 }

 .popupbody {
 background: #ddd;
 padding: 5px;
 text-align: center;
 }

 #popup1 { top: 100px; left: 50px; }

 #popup2 { top: 100px; left: 400px; }

 </style>

 <script type="text/javascript">

 var fadeOpacity  = new Array();
 var fadeTimer    = new Array();
 var fadeInterval = 100;  // milliseconds

 function fade(o,d)
 {

 // o - Object to fade in or out.
 // d - Display, true =  fade in, false = fade out

 var obj = document.getElementById(o);

 if((fadeTimer[o])||(d&&obj.style.display!='block')||(!d&&obj.style.display=='block'))
 {

 if(fadeTimer[o])
 clearInterval(fadeTimer[o]);
 else
 if(d) fadeOpacity[o] = 0;
 else  fadeOpacity[o] = 9;

 obj.style.opacity = "."+fadeOpacity[o].toString();
 obj.style.filter  = "alpha(opacity="+fadeOpacity[o].toString()+"0)";

 if(d)
 {
 obj.style.display = 'block';
 fadeTimer[o] = setInterval('fadeAnimation("'+o+'",1);',fadeInterval);
 }
 else
 fadeTimer[o] = setInterval('fadeAnimation("'+o+'",-1);',fadeInterval);
 }
 }

 function fadeAnimation(o,i)
 {

 // o - o - Object to fade in or out.
 // i - increment, 1 = Fade In

 var obj = document.getElementById(o);
 fadeOpacity[o] += i;
 obj.style.opacity = "."+fadeOpacity[o].toString();
 obj.style.filter  = "alpha(opacity="+fadeOpacity[o].toString()+"0)";

 if((fadeOpacity[o]=='9')|(fadeOpacity[o]=='0'))
 {
 if(fadeOpacity[o]=='0')
 obj.style.display = 'none';
 else
 {
 obj.style.opacity = "1";
 obj.style.filter  = "alpha(opacity=100)";
 }

 clearInterval(fadeTimer[o]);
 delete(fadeTimer[o]);
 delete(fadeTimer[o]);
 delete(fadeOpacity[o]);

 }
 }

 </script>

 </head>
 <body>

 popup1',true);"/>
 popup2',true);"/>

 popup1"></pre>
<div>Fade Popup 1</div>
<pre>
 <div>
 <p>Press close to fade out this Popup</p>
 <input type="button" value="Close" onClick="fade('popup1',false);"/>
 </div>
 </div>

 popup2"></pre>
<div>Fade Popup 2</div>
<pre>
 <div>
 <p>Press close to fade out this Popup</p>
 <input type="button" value="Close" onClick="fade('popup2',false);"/>
 </div>
 </div>

 </body>

</html>