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 | |
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 | |
// event.pt.php | |
/** | |
* Use namespace to avoid conflict | |
*/ | |
namespace PostType; | |
/** | |
* Class Portfolio |
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 | |
// Remove auto p from Contact Form 7 shortcode output | |
add_filter('wpcf7_autop_or_not', 'wpcf7_autop_return_false'); | |
function wpcf7_autop_return_false() { | |
return false; | |
} |
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 | |
$tax_query[] = array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'name', | |
'terms' => 'featured', | |
'operator' => 'IN', // or 'NOT IN' to exclude feature products | |
); | |
// The query | |
$query = new WP_Query( array( | |
'post_type' => 'product', |
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); |
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 | |
// query for your post type | |
$products = new WP_Query( | |
array ( | |
'post_type' => 'product', | |
'posts_per_page' => -1 | |
) | |
); | |
// we need the array of posts | |
$posts_array = $products->posts; |
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 prefix_user_role() { | |
$user_meta = get_userdata(get_the_author_meta( 'ID' )); | |
$user_roles = $user_meta->roles; //array of roles the user is part of. | |
echo !empty($user_roles[0]) ? $user_roles[0] : ''; | |
} |