Check if Current Category has Children

There may or may not be a better way to do this, but here’s how I would do it: $term = get_queried_object(); $children = get_terms( $term->taxonomy, array( ‘parent’ => $term->term_id, ‘hide_empty’ => false ) ); // print_r($children); // uncomment to examine for debugging if($children) { // get_terms will return false if tax does not exist … Read more

Get the first image from post content (eg.: hotlinked images)

If you want display an image that is inserted into your content (a hotlinked image, for example), you must use a function like this (source): add in functions.php: function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img … Read more