/i', $post->post_content, $matches); if ( 0 != $output ) { $first_img = $matches [1][0]; } return $first_img; } endif; /** * Helper function * @see letterum_hover_class * Post preview background image */ if ( ! function_exists( 'letterum_hover_bg' ) ) : function letterum_hover_bg() { if ( letterum_catch_image() && has_post_thumbnail() && has_post_format('image') ) { echo ' '; echo 'style="background-image: url(' . esc_url( letterum_catch_image() ) . ' );"'; } } endif; /** * Adds custom classes to the array of post classes. * For to change images when hover * Post preview background image */ function letterum_hover_class( $classes ) { if ( letterum_catch_image() && has_post_thumbnail() && has_post_format('image') && ! is_single() ) { $classes[] = 'hover-bg'; } return $classes; } add_action( 'post_class', 'letterum_hover_class' ); /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function letterum_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'letterum_pingback_header' ); /** * The frontpage or not. */ function letterum_is_frontpage() { return ( is_front_page() && ! is_home() ); } /** * Return an alternative title, without prefix * for every type used in the get_the_archive_title(). */ function letterum_remove_archive_title_prefix( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $title = single_tag_title( '#', false ); } elseif ( is_author() ) { $title = '' . get_the_author() . ''; } elseif ( is_year() ) { $title = get_the_date( 'Y' ); } elseif ( is_month() ) { $title = get_the_date( 'F Y' ); } elseif ( is_day() ) { $title = get_the_date( get_option( 'date_format' ) ); } elseif ( is_tax( 'post_format' ) ) { if ( is_tax( 'post_format', 'post-format-aside' ) ) { $title = esc_html( _x( 'Asides', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = esc_html( _x( 'Galleries', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = esc_html( _x( 'Images', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = esc_html( _x( 'Videos', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = esc_html( _x( 'Quotes', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = esc_html( _x( 'Links', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = esc_html( _x( 'Statuses', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = esc_html( _x( 'Audio', 'post format archive title', 'letterum' ) ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = esc_html( _x( 'Chats', 'post format archive title', 'letterum' ) ); } } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } else { $title = __( 'Archives', 'letterum' ); } return $title; } add_filter( 'get_the_archive_title', 'letterum_remove_archive_title_prefix' ); /** * Custom style more link */ function letterum_read_more_link() { return '' . esc_html__( 'Read More', 'letterum' ) . ''; } //add_filter( 'the_content_more_link', 'letterum_read_more_link' ); //add_filter( 'excerpt_more', 'letterum_read_more_link' ); /** * Append a search icon to the primary menu * This is a sample function to show how to append an icon to the menu based on the customizer search option * The search icon wont actually do anything */ if ( ! function_exists( 'letterum_add_search_menu_item' ) ) { function letterum_add_search_menu_item( $items, $args ) { if( get_theme_mod( 'search_menu_icon' ) == true ) { if( $args->theme_location == 'primary' ) { $items .= ''; } } return $items; } } add_filter( 'wp_nav_menu_items', 'letterum_add_search_menu_item', 10, 2 );