Wednesday, March 30, 2011

How to remove WordPress admin bar from front end

In the following process you can  remove WordPress 3.1 admin bar

WordPress 3.1 introduced a new feature: the admin bar. It is very useful, but if you like to remove it. Please follow the instruction.

Paste the following piece of code into your functions.php file, save it to remove admin bar.

wp_deregister_script('admin-bar');
wp_deregister_style('admin-bar');
remove_action('wp_footer','wp_admin_bar_render',1000);

Thursday, March 24, 2011

How to replace words in your wordpress posts

Replace words in your wordpress posts

Let your Wordpress blog was named “portfolio” and you renamed it “myportfolio”. Then don’t edit your xxx posts to replace every single occurence! With this very useful code will do it for you, like a magic!


Just put words to replace in the array on line 4. Once done, paste the code into your function.php file, save the file, and you're ready!

function replace_text_wps($text){
   $replace = array(
       // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
       'portfolio' => 'myportfolio',
       'excerpt' => 'excerpt',
       'function' => 'function'
   );
   $text = str_replace(array_keys($
replace), $replace, $text);
   return $text;
}

add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');

Tuesday, February 1, 2011

How to increase WordPress memory limit

If ever this happen “Allowed memory size of xxx bytes exhausted”, then we need to increase WordPress memory limit. This can be done


open your wp-config file and paste the following code in it.

define('WP_MEMORY_LIMIT', '96M');

Monday, January 31, 2011

Set An Expiration Time For Wordpress Posts

Set An Expiration Time For Wordpress Posts:

Sometimes (like, when we are running a contest), We want to be able to publish a post and then automatically stop displaying it after a certain date. This may seem quite hard to do but using the custom field we can do this easyly.

To do this Edit the WP theme and replace the current WordPress loop with this "modified" code:


if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}

$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
// For example...
the_title();
the_excerpt();
}
endwhile;
endif;



To create a post set to expire at a certain date and time, Like create a custom field. Specify expiration as a key and your date and time as a value (with the format mm/dd/yyyy 00:00:00). The post will not show up after the time on that stamp


**This code does not remove or unpublish post, It just prevents it from being displayed in the loop.

Thursday, January 6, 2011

How to make capital letters with CSS style

You can capitalize words and letters with this css.

.classname{
text-transform: capitalize;
}

This is make Abcde to Abcde

.classname{
text-transform: uppercase;
}

This is make abcde to ABCDE

Friday, December 24, 2010

What is Type Juggling in php

Type Juggling in php:

PHP does not require explicit type definition in variable declaration. a variable's type is determined by the context in which that variable is used. That is, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer.

An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.

$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)

If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined

What are the functions for IMAP?

Internet Message Access Protocol:

imap_body : Read the message body
imap_check : Check current mailbox
imap_delete : Mark a message for deletion from current mailbox
imap_mail : Send an email message

Friday, November 19, 2010

What are the database space-saving functions available in php ?

# Use ip2long() and long2ip() to store the IP adresses as Integers instead
of storing them as strings, which will reduce the space from 15 bytes to 4
bytes. This will also increase search speed and make it easy to see if a ip
falls within a specified range.

# Use gzcompress() and gzuncompress() to reduce the strings before you
store them in a database. The gzcompress can compress plain-text up to 90%.
The only reason why you shouldn’t use it is when you need full-text
indexing capabilities.

How can we save an image from a remote web server to my web server using PHP?

$file_rimg = fopen("http://w3answers /image23.jpg",'rb');
$newfile_name_img = "/tmp/tutorial.file";
$file_wnew = fopen($newfile_name_img,'wb');
while (!feof($file_rimg)) {
$chunk_rd = fread($file_rimg,1024);
fwrite($file_wnew,$chunk_rd);
}
fclose($file_wnew);
fclose(file_rimg);

Is Single Quotes better then double quotes

By using single quotes instead of double quotes, we save PHP from having
to parse your string for variables. It's not only is faster, but I find it
more programmer-friendly because it is easier to find variables in your
code.
Also, when referencing an array that has a string index, always use single
quotes. This prevents PHP from having to figure out exactly what you were
trying to say.

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off