View string_parts.php
<?php | |
// When you want to split strings by spaces without rounding up | |
function string_parts($string, $parts = 2) | |
{ | |
$array = preg_split('/\s+/', $string); | |
if (! (count($array) > 1)) { | |
return $string; | |
} |
View getPostThumbnail.php
<?php | |
function nb_get_post_thumbnail( $post_id = null, $size = 'medium', $attr = [] ) { | |
if(!$post_id) { | |
$post_id = get_the_ID(); | |
} | |
// Step 1: Use the featured image if it's there | |
if(!empty($image = get_the_post_thumbnail($post_id, $size, $attr))) { | |
return $image; |