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 | |
// 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; | |
} |
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 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; |