Posts

Showing posts from 2016

Disable plugin update notification in wordpress

Add below code on your current theme's functions.php and add plugin base file name under unset . add_filter( 'site_transient_update_plugins', 'remove_wp_update_notifications' ); function remove_wp_update_notifications( $value ){ if ( isset( $value ) && is_object( $value ) ){ unset( $value->response[ 'hello.php' ] ); unset( $value->response[ 'js_composer/js_composer.php' ] ); } return $value; }

Featured image option not displaying in wordpress admin panel

When you are developing a fresh wordpress theme then you need Add this code to the themes functions.php : add_theme_support ( 'post-thumbnails' );

Redirect page using jQuery

You can use following methods to redirect a page using jQuery window.location.replace("http://www.keredari.com"); window.location.href = "http:// www.keredari .com"; $(location).attr('href', 'http://www.keredari.com'); $(window).attr("location","http://www.keredari.com");

Get wordpress posts and featured Image via direct sql query

Use below MySql query to get wordpress posts with featured image SELECT p1 .*, wm2 . meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1 ON ( wm1 . post_id = p1 . id AND wm1 . meta_value IS NOT NULL AND wm1 . meta_key = "_thumbnail_id" ) LEFT JOIN wp_postmeta wm2 ON ( wm1 . meta_value = wm2 . post_id AND wm2 . meta_key = "_wp_attached_file" AND wm2 . meta_value IS NOT NULL ) WHERE p1 . post_status = "publish" AND p1 . post_type = "post" ORDER BY p1 . post_date DESC

add join in datatables using codeigniter

Sets join statement variables. If you want DataTables to include data from another table, you can define an a table along with its columns and foreign key relationship. $this->datatables->join('states', 'cities.state_id = states.id', 'left'); $this->datatables->select('cities.id,cities.name,states.name as state_name') ->from('cities'); 

Add minimum charge in Woocommerce cart page

// Paste below code in your active theme s functions.php add_action( 'woocommerce_cart_calculate_fees', ' wc_add_minimum_fee ' ); function wc_add_minimum_fee (){ global $woocommerce; $stotal = $woocommerce->cart->subtotal; if ($ stotal < 999 ) { $surcharge = 100; } else { $surcharge = 0; } $woocommerce->cart->add_fee( __('Surcharge', 'woocommerce'), $surcharge ); }

Login with email or username in codeigniter

function login_user() { $email= $this->input->post('email'); $password= MD5($this->input->post('password')); $this->db->where("(Email='$email' OR Username='$email') AND Password='$password' "); $Query = $this->db->get('users'); if($Query->num_rows() > 0) { return $Query->row(); } else { return false; } }

Convert JSON string to Array in php

$json_string = '{ "title": "PHP: The Definitive Guide", "author": "Arun Verma", }' ; $res = json_decode ( $json , true ) ; echo $res [ 'title' ] ; // PHP: The Definitive Guide