/** * Filter Default WP Title Tag * Modified from Hybrid Core Library. * * @since 0.1.0 */ function tamatebako_wp_title($doctitle) { /* Do not filter RSS feed title */ if (is_feed()) { return $doctitle; } /* Variable */ $site_title = get_bloginfo('name'); $site_description = get_bloginfo('description', 'display'); if (is_front_page()) { $doctitle = $site_title; } elseif (is_home()) { $doctitle = single_post_title('', false); } elseif (is_singular()) { $doctitle = single_post_title('', false); } elseif (is_category()) { $doctitle = single_cat_title('', false); } elseif (is_tag()) { $doctitle = single_tag_title('', false); } elseif (is_tax()) { $doctitle = single_term_title('', false); } elseif (is_post_type_archive()) { $doctitle = post_type_archive_title('', false); } elseif (is_author()) { $doctitle = get_the_author_meta('display_name', get_query_var('author')); } elseif (get_query_var('minute') && get_query_var('hour')) { $doctitle = hybrid_single_minute_hour_title('', false); } elseif (get_query_var('minute')) { $doctitle = hybrid_single_minute_title('', false); } elseif (get_query_var('hour')) { $doctitle = hybrid_single_hour_title('', false); } elseif (is_day()) { $doctitle = hybrid_single_day_title('', false); } elseif (get_query_var('w')) { $doctitle = hybrid_single_week_title('', false); } elseif (is_month()) { $doctitle = single_month_title(' ', false); } elseif (is_year()) { $doctitle = hybrid_single_year_title('', false); } elseif (is_archive()) { $doctitle = hybrid_single_archive_title('', false); } elseif (is_search()) { $doctitle = hybrid_search_title('', false); } elseif (is_404()) { $doctitle = hybrid_404_title('', false); } /* Add Site Description only in front page */ if (is_front_page()) { if ($site_description) { $doctitle = "{$doctitle}: {$site_description}"; } } else { $doctitle = "{$doctitle} – {$site_title}"; } /* If the current page is a paged. */ if ((($page = get_query_var('paged')) || ($page = get_query_var('page'))) && $page > 1) { $page = number_format_i18n(absint($page)); $doctitle = sprintf(tamatebako_string('paged'), $doctitle . " | ", $page); } return trim(strip_tags($doctitle)); }
/** * Gets the loop title. This function should only be used on archive-type pages, such as archive, blog, and * search results pages. It outputs the title of the page. * * @link http://core.trac.wordpress.org/ticket/21995 * @since 2.0.0 * @access public * @return string */ function hybrid_get_loop_title() { $loop_title = ''; if (is_home() && !is_front_page()) { $loop_title = get_post_field('post_title', get_queried_object_id()); } elseif (is_category()) { $loop_title = single_cat_title('', false); } elseif (is_tag()) { $loop_title = single_tag_title('', false); } elseif (is_tax()) { $loop_title = single_term_title('', false); } elseif (is_author()) { $loop_title = hybrid_single_author_title('', false); } elseif (is_search()) { $loop_title = hybrid_search_title('', false); } elseif (is_post_type_archive()) { $loop_title = post_type_archive_title('', false); } elseif (get_query_var('minute') && get_query_var('hour')) { $loop_title = hybrid_single_minute_hour_title('', false); } elseif (get_query_var('minute')) { $loop_title = hybrid_single_minute_title('', false); } elseif (get_query_var('hour')) { $loop_title = hybrid_single_hour_title('', false); } elseif (is_day()) { $loop_title = hybrid_single_day_title('', false); } elseif (get_query_var('w')) { $loop_title = hybrid_single_week_title('', false); } elseif (is_month()) { $loop_title = single_month_title(' ', false); } elseif (is_year()) { $loop_title = hybrid_single_year_title('', false); } elseif (is_archive()) { $loop_title = hybrid_single_archive_title('', false); } return apply_filters('hybrid_loop_title', $loop_title); }
/** * Filters the `wp_title` output early. * * @since 2.0.0 * @access publc * @param string $title * @param string $separator * @param string $seplocation * @return string */ function hybrid_wp_title($doctitle, $separator, $seplocation) { /* Custom separator for backwards compatibility. */ $separator = ':'; if (is_front_page()) { $doctitle = get_bloginfo('name') . $separator . ' ' . get_bloginfo('description'); } elseif (is_home() || is_singular()) { $doctitle = single_post_title('', false); } elseif (is_category()) { $doctitle = single_cat_title('', false); } elseif (is_tag()) { $doctitle = single_tag_title('', false); } elseif (is_tax()) { $doctitle = single_term_title('', false); } elseif (is_post_type_archive()) { $doctitle = post_type_archive_title('', false); } elseif (is_author()) { $doctitle = hybrid_single_author_title('', false); } elseif (get_query_var('minute') && get_query_var('hour')) { $doctitle = hybrid_single_minute_hour_title('', false); } elseif (get_query_var('minute')) { $doctitle = hybrid_single_minute_title('', false); } elseif (get_query_var('hour')) { $doctitle = hybrid_single_hour_title('', false); } elseif (is_day()) { $doctitle = hybrid_single_day_title('', false); } elseif (get_query_var('w')) { $doctitle = hybrid_single_week_title('', false); } elseif (is_month()) { $doctitle = single_month_title(' ', false); } elseif (is_year()) { $doctitle = hybrid_single_year_title('', false); } elseif (is_archive()) { $doctitle = hybrid_single_archive_title('', false); } elseif (is_search()) { $doctitle = hybrid_search_title('', false); } elseif (is_404()) { $doctitle = hybrid_404_title('', false); } /* If the current page is a paged page. */ if ((($page = get_query_var('paged')) || ($page = get_query_var('page'))) && $page > 1) { /* Translators: 1 is the page title. 2 is the page number. */ $doctitle = sprintf(__('%1$s Page %2$s', 'hybrid-core'), $doctitle . $separator, number_format_i18n(absint($page))); } /* Trim separator + space from beginning and end. */ $doctitle = trim(strip_tags($doctitle), "{$separator} "); return $doctitle; }