function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_postcode'] = array(
'label' => __('Postcode', 'woocommerce'),
'placeholder' => _x('Postcode', 'placeholder', 'woocommerce'),
'required' => true,
'clear' => false,
'type' => 'select',
'class' => array('update_totals_on_change'),
'options' => array(
'E1' => __('E1', 'woocommerce' ),
'E2' => __('E2', 'woocommerce' )
)
);
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
Sunday, May 24, 2015
Wordpress woocommerce shipping payment change on postcode
Thursday, February 19, 2015
How to include redux framework in your theme functions.php
if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( __FILE__ ) . '/redux-framework/ReduxCore/framework.php' ) ) {
require_once( dirname( __FILE__ ) . '/redux-framework/ReduxCore/framework.php' );
}
if ( !isset( $redux_demo ) && file_exists( dirname( __FILE__ ) . '/redux-framework/sample/sample-config.php' ) ) {
require_once( dirname( __FILE__ ) . '/redux-framework/sample/sample-config.php' );
}
Hook wp_enqueue_scripts load in header and footer
function load_scripts_basic() {
global $wp_scripts;
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
wp_enqueue_style( 'style-bootstrap', get_template_directory_uri().'/css/bootstrap.min.css' );
wp_enqueue_style( 'style-normalize', get_template_directory_uri().'/css/normalize.css' );
wp_enqueue_style( 'style-awesome', get_template_directory_uri().'/css/font-awesome.min.css' );
wp_enqueue_style( 'style-main', get_template_directory_uri().'/css/styles.css' );
wp_enqueue_style( 'style-eng', get_template_directory_uri().'/engine1/style.css' );
wp_enqueue_script( 'jquery-min', get_template_directory_uri() . '/js/jquery.min.js', false );
wp_enqueue_script( 'jquery-res_collapse_menu', get_template_directory_uri() . '/js/res_collapse_menu.js', array(), '1.0.0', false );
wp_enqueue_script( 'jquery-fade', get_template_directory_uri() . '/js/fade.js', array(), '1.0.0', false );
wp_enqueue_script( 'bootstrap.newsbox', get_template_directory_uri() . '/js/jquery.bootstrap.newsbox.min.js', array(), '1.0.0', false );
wp_register_script('html5shiv',get_bloginfo('template_url').'/js/html5shiv.js',array(),'1.0.0');
$wp_scripts->add_data( 'html5shiv', 'conditional', 'lt IE 9' );
wp_register_script('respond.min', get_bloginfo('template_url').'/js/respond.min.js', array(), '1.0.0' );
$wp_scripts->add_data( 'respond.min', 'conditional', 'lt IE 9' );
// load script in footer
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0.0', true );
wp_enqueue_script( 'cbpAnimatedHeader', get_template_directory_uri() . '/js/cbpAnimatedHeader.js', array(), '1.0.0', true );
wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'load_scripts_basic' );
Creating a meta box for posts Titan Framework
if ( !class_exists( 'TitanFramework' ) && file_exists( dirname( __FILE__ ) . '/titan/titan-framework-embedder.php' ) ) {
require_once( dirname( __FILE__ ) . '/titan/titan-framework-embedder.php' );
}
function theme_meta_options() {
$titan = TitanFramework::getInstance( 'pmi' );
$myMetaBox = $titan->createMetaBox( array(
'name' => 'Event Option',
'post_type' =>array('post')
) );
$myMetaBox->createOption(array(
'name' => 'Event Start Date & Time',
'type' => 'date',
'id' => 'eventdatentime',
'desc' => 'Event Data & time',
'date' => true,
'time' => true
)) ;
$myMetaBox->createOption( array(
'name' => 'Venue',
'id' => 'event_venue',
'type' => 'text',
'desc' => 'Venue Address',
) );
$myMetaBox->createOption(array(
'name' => 'End Date & Time',
'type' => 'date',
'id' => 'eventenddatentime',
'desc' => 'Event End Data & time',
'date' => true,
'time' => true
)) ;
}
add_action( 'tf_create_options', 'theme_meta_options' );
Friday, October 10, 2014
Create custom add_menu_page and add_submenu_page in admin panel
function theme_options_panel(){
add_menu_page('Theme page title', 'Theme menu label', 'manage_options', 'theme-options', 'wps_theme_func');
add_submenu_page( 'theme-options', 'Settings page title', 'Settings menu label', 'manage_options', 'theme-op-settings', 'wps_theme_func_settings');
add_submenu_page( 'theme-options', 'FAQ page title', 'FAQ menu label', 'manage_options', 'theme-op-faq', 'wps_theme_func_faq');
}
add_action('admin_menu', 'theme_options_panel');
function wps_theme_func(){
}
function wps_theme_func_settings(){
}
function wps_theme_func_faq(){
}
Wednesday, May 7, 2014
Remove shortcode from the_content_rss
function filter_shortcode_from_content_rss($content) {
$content = strip_shortcodes($content);
return $content;
}
add_filter('the_content_rss', 'filter_shortcode_from_content_rss');
Thursday, February 6, 2014
Deleting WordPress Revisions
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'
Thursday, January 30, 2014
WordPress Error Reporting
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
Sunday, December 1, 2013
wordpress tax_query where taxonomy
$terms = get_terms('txnm_project', array('include' => $metaportfolio->peoductinclude));
foreach($terms as $term){
$in_area[] = $term->term_id;
}
$posts = get_posts(array(
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'txnm_project',
'terms' => $page_terms['area_term'] ? $page_terms['area_term'] : $in_area,
'field' => 'id',
)
),
'numberposts' => $metaportfolio->countperpage,
'order' => $metaportfolio->sorting ? 'ASC' : 'DESC',
));
Thursday, September 5, 2013
Thursday, July 25, 2013
custom post type with category query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'audio',
'paged' => $paged,
'posts_per_page' => 15,
'tax_query' => array(
array(
'taxonomy' => 'audio_category',
'terms' => array($cat),
'field' => 'id',
)
),
'meta_query' => array(
array(
'key' => 'singername',
'value' => $archivesinger,
'compare' => 'LIKE'
),
array(
'key' => 'albumn',
'value' => $archivealbum,
'compare' => 'LIKE'
),
),
);
Wednesday, July 24, 2013
How To Create Custom Taxonomies Fields In WordPress
<?php
add_action('category_add_form_fields','extra_category_fields');
add_action ( 'edit_category_form_fields', 'extra_category_fields');
//add extra fields to category edit form callback function
function extra_category_fields( $tag ) { $t_id = $tag->term_id;
$cat_meta = get_option( "category_$t_id");
?><tr class="form-field">
<th scope="row" valign="top"><label for="extra1"><?php _e('Category Sidebar'); ?></label></th>
<td>
<select name="Cat_meta[sidebarpage]" id="Cat_meta[sidebarpage]">
<option value=""> </option>
<option value="organization" <?php if($cat_meta['sidebarpage']=="organization") echo "selected";?>>Organization Menu </option>
<option value="culturalbuilding" <?php if($cat_meta['sidebarpage']=="culturalbuilding") echo "selected";?>>Cultural building Menu</option>
</select>
<br />
<?php //echo $cat_meta['sidebarpage'];?>
<span class="description"><?php _e('Category Sidebar design'); ?></span>
</td>
</tr>
<?php
}
add_action('create_category','save_extra_category_fileds');
add_action ( 'edited_category', 'save_extra_category_fileds');
// save extra category extra fields callback function
function save_extra_category_fileds( $term_id ) {
if ( isset( $_POST['Cat_meta'] ) ) {
$t_id = $term_id;
$cat_meta = get_option( "category_$t_id");
$cat_keys = array_keys($_POST['Cat_meta']);
foreach ($cat_keys as $key){
if (isset($_POST['Cat_meta'][$key])){
$cat_meta[$key] = $_POST['Cat_meta'][$key];
}
}
//save the option array
update_option( "category_$t_id", $cat_meta );
}
}
Monday, July 15, 2013
Add Pop-up Windows to Your WordPress
add_action('init', 'init_theme_method');
function init_theme_method() {
add_thickbox();
}
<div style="text-align:center;padding:20px;"><input alt="#TB_inline?height=300&width=400&inlineId=examplePopup1" title="add a caption to title attribute / or leave blank" class="thickbox" type="button" value="Show Thickbox Example Pop-up 1" /></div>
<div id="examplePopup1" style="display:none"><h2>Example Pop-up Window 1</h2><div style="float:left;padding:10px;"><img src="http://shibashake.com/wordpress-theme/wp-content/uploads/2010/03/bio1.jpg" width="150" height = "168"/>I was born at DAZ Studio. They created me with utmost care and that is why I am the hottie that you see today. My interests include posing, trying out cute outfits, and more posing.</div>
Sunday, June 16, 2013
WordPress How-To: Force Direct Filewrites For Upgrades
define( 'FS_METHOD', 'direct' ); define( 'FS_CHMOD_DIR', 0777 ); define( 'FS_CHMOD_FILE', 0777 );
How to Update WordPress Automatically Without Using FTP
define( 'FS_METHOD', 'direct' );
Saturday, June 15, 2013
wordpress meta value search(Multisite Global Search plugin)
$termsearch = "( post_title LIKE '%%".$term."%%' OR post_content LIKE '%%".$term."%%' OR ".$wpdb->base_prefix."v_postmeta.meta_value LIKE '%%".$term."%%' ) ";
$request = $wpdb->prepare( "SELECT ".$wpdb->base_prefix."v_posts.* from ".$wpdb->base_prefix."v_posts left join ".$wpdb->users." on ".$wpdb->users.".ID=".$wpdb->base_prefix."v_posts.post_author ". " LEFT JOIN ".$wpdb->base_prefix."v_postmeta ON(".$wpdb->base_prefix."v_posts.ID = ".$wpdb->base_prefix."v_postmeta.post_id)".
Wednesday, June 12, 2013
How Can I add a WordPress menu to the content of my page?
function content_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
add_shortcode('menu', 'content_menu_shortcode');
[menu name="content-menu"]
Sunday, June 9, 2013
Display multiple custom field values with the same custom field type
$beedroomsbefore = get_post_meta($post->ID, 'bedroomsbefore', false);
if ($beedroomsbefore) {
foreach ($bedroomsbefore as $bedroomsbefore) {
echo '
';
}
}
Wednesday, May 15, 2013
Nextgen gallery WYSIWYG description area(just gallery description not for gallery picture description)
$editor_id = "gallerydesc";
$tacontent = stripslashes($gallery->galdesc);
wp_editor($tacontent,$editor_id,array("media_buttons"=>FALSE,"textarea_name"=>$editor_id,"teeny"=>true,"textarea_rows"=>4,"editor_css"=>"","quicktags"=>false,"tinymce"=>array("theme_advanced_buttons1"=>"bold, italic, underline, blockquote, separator, strikethrough, link, unlink") ));