is_search) { $query->set('post_type', 'post'); } return $query; } add_filter('pre_get_posts','bloganagel_search_filter'); function th_grid_thumb($grid_layout, $thumb_crop=true){ if($thumb_crop): switch($grid_layout){ case 'two-grid-layout': the_post_thumbnail('custom-two-grid-thumb'); break; case 'three-grid-layout': the_post_thumbnail('custom-three-grid-thumb'); break; case 'four-grid-layout': the_post_thumbnail('custom-four-grid-thumb'); break; case 'list-layout': the_post_thumbnail('custom-list-thumb'); break; case 'boxed-layout': the_post_thumbnail('custom-boxed-thumb'); break; } else: switch($grid_layout){ case 'two-grid-layout': echo th_post_image(562, 320); break; case 'three-grid-layout': echo th_post_image(358, 204); break; case 'four-grid-layout': echo th_post_image(257, 146); break; case 'list-layout': echo th_post_image(300, 300); break; case 'boxed-layout': echo th_post_image(585, 333); break; } endif; } /* * Custom header menu * */ add_action( 'after_setup_theme', 'register_theme_menu' ); function register_theme_menu() { register_nav_menu( 'primary', __( 'Primary Menu', 'blogangel' ) ); } function th_nav_menu(){ wp_nav_menu( array('theme_location' => 'primary', 'container' => false, 'menu_class' => 'menu', 'menu_id' => 'menu', 'fallback_cb' => 'th_wp_page_menu')); } function th_wp_page_menu() { echo ''; } // full thumb get post content function th_full_post_image(){ $img_source = ''; global $post; $output = preg_match_all('//i', $post->post_content, $matches); if (isset($matches [1] [0])) { $img_source = $matches [1] [0]; } if($img_source!=''){ $permalink = get_permalink($post->ID); print "Post Image"; } } // post content image thumbnail function th_post_image($width, $height) { $w = $width; $h = $height; global $post; //This is required to set to Null $img_source = ''; $permalink = get_permalink($post->ID); $output = preg_match_all('//i', $post->post_content, $matches); if (isset($matches [1] [0])) { $img_source = $matches [1] [0]; } if($img_source!=''){ $img_path = th_image_resize($img_source, $w, $h); if (!empty($img_path['url'])) { print "Post Image"; } } } /** * Display navigation to next/previous post when applicable. * * @since ThemeHunk 1.0 */ if ( ! function_exists( 'th_post_nav' ) ) : function th_post_nav() { // Don't print empty markup if there's nowhere to navigate. ?> '; // tag before the current crumb $after = ''; // tag after the current crumb /* === END OF OPTIONS === */ global $post; $home_link = home_url('/'); $link_before = ''; $link_after = ''; $link_attr = ' rel="v:url" property="v:title"'; $link = $link_before . '%2$s' . $link_after; $parent_id = $parent_id_2 = $post->post_parent; $frontpage_id = get_option('page_on_front'); if (is_home() || is_front_page()) { if ($show_on_home == 1) echo ''; } else { /* xmlns:v="http://rdf.data-vocabulary.org/#"*/ echo ''; } } /** * custom post excerpt */ function get_th_custom_excerpt(){ $excerpt = get_the_content(); $excerpt = preg_replace(" (\[.*?\])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 200); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt)); $return = '

'.$excerpt.'

Read More'; return $return; } // related post function th_get_related_sigle_post() { global $post; $args = array( 'category__in' => wp_get_post_categories($post->ID), 'post__not_in' => array($post->ID), 'post_status' => array('publish'), 'meta_key' => '_thumbnail_id', 'posts_per_page' => 3, ); $my_query = new WP_Query($args); if ($my_query->have_posts()) { while ($my_query->have_posts()) : $my_query->the_post(); ?> tag based on what is being viewed. */ global $page, $paged; wp_title('|', true, 'right'); // Add the blog name. bloginfo('name'); // Add the blog description for the home/front page. $site_description = get_bloginfo('description', 'display'); if ($site_description && ( is_home() || is_front_page() )){ echo " | $site_description"; } // Add a page number if necessary: if ($paged >= 2 || $page >= 2){ echo ' | ' . sprintf(__('Page %s', 'blogangel'), max($paged, $page)); } } /*auto width and height removed*/ add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 ); function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) { $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); return $html; } function get_my_url() { if ( ! preg_match( '/]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) ){ return false; } return esc_url_raw( $matches[1] ); } /*hexa to rgba convert*/ function hex2rgba($color, $opacity = false) { $default = 'rgb(0,0,0)'; //Return default if no color provided if(empty($color)){ return $default; } //Sanitize $color if "#" is provided if ($color[0] == '#' ) { $color = substr( $color, 1 ); } //Check if color has 6 or 3 characters and get values if (strlen($color) == 6) { $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); } elseif ( strlen( $color ) == 3 ) { $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); } else { return $default; } //Convert hexadec to rgb $rgb = array_map('hexdec', $hex); //Check if opacity is set(rgba or rgb) if($opacity){ if(abs($opacity) > 1){ $opacity = 1.0; } $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; } else { $output = 'rgb('.implode(",",$rgb).')'; } //Return rgb(a) color string return $output; } /*Number of comment*/ function comment_number(){ ?>