Posts

Showing posts from June, 2015

How to add a custom column in custom post type list in admin side wordpress

For add a custom column in admin side list for custom post type or any post type just copy and paste below code into your theme's functions.php function rj_display_rank_column_data( $column, $post_id ) {     global $wpdb;     switch ( $column ) {         case 'rank' :                     $rank = get_post_meta($post_id,'optimus_rank_field',true);                if($rank!='9999' && $rank!='')                {                 echo $rank;                }else               ...

How to change wp_nav_menu walker or any other argument by filter in wordpress

For change wp_nav_menu argument for specific menu or all menu or change walker class for menu just copy and paste below code into your theme's functions.php file and change menu slug as per your need add_filter('wp_nav_menu_args','rj_change_walker_for_footer_menus',10,1); function rj_change_walker_for_footer_menus($args) {     global $wpdb;     if($args['menu']!='' && in_array($args['menu']->slug,array('footer-menu1','footer-menu2','footer-menu3')))     {         $args['fallback_cb']           = 'RJFusionFootermenuWalker::fallback';             $args['walker']    =new RJFusionFootermenuWalker();     }     return $args; }

How to change navigation menu display style in wordpress

<?php For change navigation menu display style you need to call your custom walker class. When you can your navgation menu just add walker argument in it and initialize your walker class.. wp_nav_menu(array(                 'theme_location'    => 'main_navigation',                 'depth'                => 5,                 'menu_class'          => 'fusion-menu',                 'items_wrap'         => '<ul id="%1$s" class="%2$s">%3$s</ul>',         ...

How to change cart product price dynamically in woocommerce worpdress

For change cart product price dynamically just copy and paste below code in your theme's functions.php and change code according to your need. add_action( 'woocommerce_get_price', 'rj_bill_payment_price_change_for_customer',10, 2 ); function rj_bill_payment_price_change_for_customer( $price, $product ) {     global $wpdb,$post,$woocommerce;     // do stuff here as per your need     return $price; }

How to change realted product thumbnail size in woocommerce single product page wordpress

For change the related product thumbnail size in single product page woocommerce paste below code in your theme's functions.php file below code is tested and works fine. add_action( 'after_setup_theme', 'rj_remove_loop_thumbnail_filter', 10 ); function rj_remove_loop_thumbnail_filter() {     remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); } add_filter('woocommerce_related_products_args','rj_related_product_args'); function rj_related_product_args($query_args) {     if( is_singular( 'product' ) ) {    if( ! empty( $query_args ) ) {             set_query_var( 'related_products', true );         }     }     return $query_args; } remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); add_action(...

How to add a custom email functionality in woocommerce,wordpress for example new email template for shipping order

How to add a custom email template option in woocommerce Just copy and paste below code in your theme's functions.php <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly /**  * A custom shipping WooCommerce Email class  *  * @since 0.1  * @extends \WC_Email  */  if(!class_exists('WC_Shipping_Email'))  {     include_once WP_PLUGIN_DIR.'/woocommerce/includes/emails/class-wc-email.php' ; class WC_Shipping_Email extends WC_Email {     public function __construct() {     if ( ! class_exists('Emogrifier') ){             require_once( 'includes/emogrifier/Emogrifier.php' );         }     $this->id = 'wc_shipping_email';         $this->title = 'Shipping Order';         $this->description = 'Shipping Order Notification emails are sent ...

How to change related product thumbnail size for display in single product page woocommerce wordpress -Solved

How to change related product thumbnail size for display in single product page woocommerce wordpress Solved below code is tested and works fine. add_action( 'after_setup_theme', 'rj_remove_loop_thumbnail_filter', 10 ); function rj_remove_loop_thumbnail_filter() {     remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); } add_filter('woocommerce_related_products_args','rj_related_product_args'); function rj_related_product_args($query_args) {     if( is_singular( 'product' ) ) {    if( ! empty( $query_args ) ) {             set_query_var( 'related_products', true );         }     }     return $query_args; } remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); add_action( 'woocommerce_before_shop...

How to add a custom field in custom taxonomy or how to add a image field for custom taxonomy like woocommerce produc_cat in wordpress

How to add a custom field in custom taxonomy or how to add a image field for custom taxonomy like woocommerce produc_cat in wordpress For add a custom field in custom taxonomy or add a image field for custom taxonomy just copy below code and add it into your theme's functions.php file and change a taxonomy slug as per your need. // actual action for add add_action( '{custom-taxonomy-slug}_add_form_fields', 'rj_video_categories_add_category_fields' ); //actual action for edit  add_action( '{custom-taxonomy-slug}_edit_form_fields','rj_video_categories_edit_category_fields'  ); add_action( 'video-categories_add_form_fields', 'rj_video_categories_add_category_fields' ); add_action( 'video-categories_edit_form_fields','rj_video_categories_edit_category_fields'  ); function rj_video_categories_add_category_fields() { global $wpdb; ?> <div class="form-field"> <label><?php _e...

How to add categories and tags option in custom post type in wordpress

How to add categories and tags option in custom post type. Just copy and paste below code into your theme's functions.php  function rj_register_post_type() { register_post_type('games',     array(     'description' => 'Game custom post type',         'show_ui' => true,         'exclude_from_search' => false,         'labels' => array(             'name' => 'Games',             'singular_name' => 'Game',             'add_new' => 'Add New Games',             'add_new_item' => 'Add New Game',             'edit' => 'Edit Games',             'edit_item' => 'Edit Game',...

Read all sub directories and check images or read image

For Read all images from the specific folders use below code $directories = glob($dir_path . '/*' , GLOB_ONLYDIR); if(count($directories)>0) {     foreach($directories as $sub_dir)     {         if(is_dir($sub_dir))         {                        //$images = glob($sub_dir.'/' . "*.jpg");            $images =  scandir($sub_dir.'/');             $scanned_directory = array_diff($images, array('..', '.'));                         foreach($scanned_directory as $image)             {      ...

How to change texonomy page or archive page title in wordpress

For change archive page title or customize archive page title just paste below code into your theme's functions.php file and change as per your need. add_filter( 'get_the_archive_title', 'rj_customize_archive_page_title',10,1 ); function rj_customize_archive_page_title($title) {     if ( is_category() ) {             $title = single_cat_title( '', false );         } elseif ( is_tag() ) {             $title = single_tag_title( '', false );         } elseif ( is_author() ) {             $title = '<span class="vcard">' . get_the_author() . '</span>' ;         }elseif ( is_tax('video-categories') || is_tax('video_tag') ) {             $term =...

How to add a custom field or meta box in wordpress post or any custom post type in admin side

For add a meta box or custom filed to your any post type  just copy below code and add it into your theme's functions.php file and change according to you need. function rj_feature_video_add_meta_box() {     $screens = array( 'firework-video' );   // change post type slugs     foreach ( $screens as $screen ) {         add_meta_box(             'feature_video_fireworks',             __( 'Feature Video', 'flatsome' ),             'rj_feature_video_fireworks_meta_box_callback',             $screen         );     } } add_action( 'add_meta_boxes', 'rj_feature_video_add_meta_box' ); function rj_feature_video_fireworks_meta_box_callback( $post ) {     wp_nonce_field( 'rj_feature_v...

How to add a custom post type in wordpress

For add a custom post type in your wordpress site. just copy below code and paste it into your theme's functions.php file and change name and slug as you want. add_action( 'init', 'rj_post_type_fireworks_video' ); function rj_post_type_fireworks_video() {     $labels = array(         'name'               => _x( 'Fireworks Video', 'post type general name', 'flatsome' ),         'singular_name'      => _x( 'Fireworks Video', 'post type singular name', 'flatsome' ),         'menu_name'          => _x( 'Fireworks Videos', 'admin menu', 'flatsome' ),         'name_admin_bar'     => _x( 'Fireworks Video', 'add new on admin bar', 'flatsome' ),         'add_ne...

How to add a custom product page dropdown option in front end shop or categories pages in woocommerce wordpress

How to give a option to customer for display product as they want For add a custom dropdown on shop or category page , paste below code to your functions.php file of your current active theme. // below action add a new custom dropdown box to shop or category page add_action( 'woocommerce_before_shop_loop', 'rj_product_per_page_dropdown', 25 ); function rj_product_per_page_dropdown() {     global $wp_query,$woocommerce;         $action = '';         $cat     = '';         $cat     = $wp_query->get_queried_object();         $query_string = ! empty( $_SERVER['QUERY_STRING'] ) ? '?' . add_query_arg( array( 'rj_pro_page' => false ), $_SERVER['QUERY_STRING'] ) : null;         if ( isset( $cat->term_id ) && isset( $cat->taxonomy ) ) :         ...

How to add a custom taxonomy field in woocommerce product category or any other custom taxonomy in wordpress

For add a custom taxonomy  field in product category or any other custom taxonomy Add below code in functions.php file of your theme. function product_cat_add_video_field_rj() {         ?>     <div class="form-field">         <label for="term_meta[video_link]"><?php _e( 'Video Link', 'flatsome' ); ?></label>         <input type="text" name="term_meta[video_link]" id="term_meta[video_link]" value="">         <p class="description"><?php _e( 'Enter a Video Link','flatsome' ); ?></p>     </div> <?php } function product_cat_edit_video_field_rj($term) {     $t_id = $term->term_id;     $term_meta = get_option( "taxonomy_$t_id" ); ?>     <tr class="form-field">     <th scope="row" valign="top"><labe...