This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
return ($count/2).' Views'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the 1ast category link | |
function Chaoz_first_category_link() { | |
$cats = get_the_terms(get_the_ID(), 'category'); | |
$cat = is_array($cats) ? get_category_link($cats[0]->term_id) : ''; | |
echo esc_url($cat); | |
} | |
// Get the first category link | |
function Chaoz_first_category_link() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Category array | |
function chaoz_cat_array($term='portfolio_cat') { | |
$cats = get_terms(array( | |
'taxonomy' => $term, | |
'hide_empty' => true | |
)); | |
$cat_array = array(); | |
$cat_array['all'] = esc_html__('All', 'gullu'); | |
foreach ($cats as $cat) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get comment count text | |
function prefix_comment_count($post_id) { | |
$comments_number = get_comments_number($post_id); | |
if($comments_number==0) { | |
$comment_text = esc_html__('No comment', 'chaoz'); | |
}elseif($comments_number == 1) { | |
$comment_text = esc_html__('One comment', 'chaoz'); | |
}elseif($comments_number > 1) { | |
$comment_text = $comments_number.esc_html__(' Comments', 'chaoz'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Day link to archive page | |
function prefix_day_link() { | |
$archive_year = get_the_time('Y'); | |
$archive_month = get_the_time('m'); | |
$archive_day = get_the_time('d'); | |
echo get_day_link( $archive_year, $archive_month, $archive_day); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Limit latter | |
function prefix_limit_latter($string, $limit_length) { | |
if (strlen($string) > $limit_length) { | |
echo substr($string, 0, $limit_length) . '...'; | |
} | |
else { | |
echo $string; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get image alt text | |
function aproch_image_alt($image_id) { | |
$image_title = get_the_title($image_id); | |
$image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true); | |
echo !empty($image_alt) ? $image_alt : $image_title; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function chaoz_icon_array($k) { | |
$v = array(); | |
foreach ($k as $kv) { | |
$kv = str_replace('-', ' ', $kv); | |
$kv = str_replace('icon', '', $kv); | |
$v[] = array_push($v, ucwords($kv)); | |
} | |
foreach($v as $key => $value) if($key&1) unset($v[$key]); | |
return array_combine($k, $v); |