Posts

remove default feed in wordpress

go to edit wp-includes/feed.php function get_default_feed() { //return apply_filters('default_feed', 'rss2'); }

how to add odd/even loop in array

1. ount the loop number for($i=0;$i if($i&1){ // ODD }else{ // EVEN } 2. odd loop itteration $oddLoop = false; foreach ($findposts as $findpost): //..... if($oddLoop=!$oddLoop){ // code for odd loop numbers }else{ // code for even loop numbers } 3. Odd ID number if ( ( $findpost->ID ) != $id ) { if($findpost->ID & 1){ // ODD }else{ //EVEN } The three ways are 1. Modulo for ( $i = 0 ; $i < 10 ; $i ++) {   if ( $i % 2 == 0 )   {     echo "even" ;   }   else   {     echo "odd" ;   } } 2. Flipping boolean value $even = true ; for ( $i = 0 ; $i < 10 ; $i ++) {   if ( $even )   {     echo "even" ;   }   else   {     echo "odd" ;   }   $even = ! $even ; } 3. mentioned boolean operator for ( $i = 0 ; $i < 10 ; $i ++) {   if ( $i & 1 == 0 )   {     echo "even" ;   }   else...

Add custom CSS classes to the wysiwyg drop-down

function ses_tinymce_css($wp) { $wp .= ',' . get_bloginfo('stylesheet_url'); return $wp; } add_filter( 'mce_css', 'ses_tinymce_css' ); or add_filter('mce_css', 'plugin_mce_css'); function plugin_mce_css() { return plugins_url().'/plugin/customTinyMCE.css'; }

Add Favicon on WordPress Blog

There are several ways to add favicon on WordPress blog 1.code on the header <link rel="shortcut icon" href=" /favicon.ico" /> <link rel="icon" type="image/png" href=" /favicon.ico"> 2. using WordPress Hook function add_theme_favicon() { ?> <link rel="shortcut icon" href=" /images/favicon.ico" > <?php } add_action('wp_head', 'add_theme_favicon');

Disable links Via jQuery

< script > $ ( function ( ) { //grab all a tags $ ( 'a' ) . each ( function ( ) { //click on a link.... $ ( this ) . click ( function ( ) { alert ( $ ( this ) . attr ( 'href' ) + ' is not available' ) ; //disable link return   false ; } ) ; } ) ; } ) ; </ script >

PHP pagination class

[PHP] class pagination { public function __construct() { } public function calculate_pages(&$total_rows, $rows_per_page, &$page_num) { $arr = array(); // calculate last page $last_page = ceil($total_rows / $rows_per_page); // make sure we are within limits $page_num = (int) $page_num; if ($page_num { $page_num = 1; } elseif ($page_num > $last_page) { $page_num = $last_page; } $upto = ($page_num - 1) * $rows_per_page; $arr['limit'] = 'LIMIT '.$upto.',' .$rows_per_page; $arr['current'] = $page_num; if ($page_num == 1) $arr['previous'] = $page_num; else $arr['previous'] = $page_num - 1; if ($page_num == $last_page) $arr['next'] = $last_page; else $arr['next'] = $page_num + 1; $arr['last'] = $last_page; $arr['info'] = 'Page ('.$page_num.' of '.$last_page.')'; $arr['pages'] = $this->get_surrounding_...

Display random image

[PHP] # Init Array $files = array(); # Get Folder if($_GET['folder']) { $folder = $_GET['folder']; } else { # Set Default Folder $folder = '/img/'; } # Set Full Path $path = $_SERVER['DOCUMENT_ROOT'] . '/' . $folder; # Open Directory if($handle = opendir($path)) { # Loop Through Directory while(false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(substr($file, -3) == 'gif' || substr($file, -3) == 'png' || substr($file, -3) == 'jpg' || substr($file, -4) == 'jpeg') $files[count($files)] = $file; } } } # Close Handle closedir($handle); # Init Random $rand = rand(0, count($files)-1); # Check Header Type # GIF if(substr($files[$random], -3) == 'gif') header("Content-type: image/gif"); # JPEG elseif(substr($files[$random], -3) == 'jpg') header("Content-type: image/jpeg"); elseif(substr($files[$rando...