check out this plugin : LINK

by using this plugin,Resize image with no crop .

after creating taxonomy-tax_slug.php page , I want to add parent taxonomy name when sub taxonomy is being viewing

 

$term = $wp_query->queried_object;
$parent_id =  $term->parent;
if($parent_id!=0){
$parent_tax_arr = get_term_by(‘id’, $parent_id, ‘tax_slug’);
echo $parent_tax_arr->name.’->’;
}
printf( __( ‘%s’, ‘your_textdomain’ ), single_cat_title( ”, false ) );

 

add_action( ‘admin_init’, ‘my_admin_init’ );
function my_admin_init() {
add_filter( ‘manage_edit-leave_columns’, ‘my_new_custom_post_column’);
add_action( ‘manage_leave_posts_custom_column’, ‘location_tax_column_info’, 10, 2);
}

function my_new_custom_post_column( $column ) {
$column[‘leave_type’] = ‘Leave Type’;

return $column;
}

function location_tax_column_info( $column_name, $post_id ) {

if($column_name==’leave_type’){
//$post_type = get_post_type($post_id);
$terms = get_the_terms($post_id, ‘leave_type’);

if (!empty($terms) ) {
foreach ( $terms as $term )
echo $term->name;
}
else echo ‘<i>No Location Set. </i>’;
}
}

Hi all,

recently I just try to add class in li tag in wp nav menu.After some search I got this:

Filter Name : nav_menu_css_class

 

function li_class($classes, $item, $args) {
$classes[] = ‘YOUR_CLASS_NAME’;  // add our class name
return $classes;
}
add_filter(‘nav_menu_css_class’,’li_class’,1,3);

 

following code will run at every 15 minutes.

if you want to use while loop inside cron function,you need to check every function inside wp_query.some times global $post variable not worked 😦

add_filter(‘cron_schedules’, ‘add_scheduled_interval’);

// add once 5 minute interval to wp schedules
function add_scheduled_interval($schedules) {
$schedules[‘minutes_my’] = array(‘interval’=>300, ‘display’=>’Once 5 minutes’);
return $schedules;
}
if (!wp_next_scheduled(‘minutes_my_cron’)) {
wp_schedule_event(time(), ‘minutes_my’, ‘minutes_my_cron’);
}
add_action(‘minutes_my_cron’, ‘min_cron_executor’);

function min_cron_executor() {

//add CODE

}

 

Simple Encrypt and Decrypt

Posted: July 31, 2015 in Uncategorized

Following code will encrypt and decrypt as per your length and data:

You can easily pass it to URL
function randomstring_ENCRYPT($post_ad_id,$length){

$characters = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
$charactersLength = strlen($characters);
$randomString = ”;
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength – 1)];
}

$encode =rtrim(strtr(base64_encode($randomString.$post_ad_id), ‘+/’, ‘-_’), ‘=’);

return $encode;

}

function randomstring_DESCRPT($data,$length){

$post_ad_id = base64_decode(str_pad(strtr($data, ‘-_’, ‘+/’), strlen($data) % 4, ‘=’, STR_PAD_RIGHT));

$pid = substr($post_ad_id, $length);

return $pid;

}