function get_page_title($prefix = "", $separator = "") { $title = ""; if (is_category()) { $category = get_category(get_query_var('cat'), false); $title = get_cat_name($category->cat_ID); } if (is_post_type_archive()) { $title = get_post_type_singular_name(); } if (is_single() || is_page()) { $title = get_the_title(); } if (is_search()) { $title = "Ricerca"; } if (is_front_page()) { return $prefix; } return "{$prefix}{$separator}{$title}"; }
/** * Returns the page title. * * @param string $prefix (optional) * A string to be prefixed to the current page title. * @param string $separator (optional) * A string to separate prefix and current page title. * * @return string * The page title * * @ingroup helperfunc */ function get_page_title($prefix = "", $separator = "") { $title = ""; if (is_category()) { $category = get_category(get_query_var('cat'), false); $title = get_cat_name($category->cat_ID); } if (is_post_type_archive()) { $title = get_post_type_singular_name(); } if (is_single() || is_page()) { $title = get_the_title(); } if (is_search()) { $title = sprintf(__("Search: %s", "wl"), get_search_query()); } if (is_date()) { if (is_month()) { $date = get_the_date("F Y"); } else { if (is_year()) { $date = get_the_date("Y"); } else { $date = get_the_date(); } } $title = sprintf(__("Archives: %s", "wl"), $date); } if (is_front_page() || is_home()) { $title = get_bloginfo("description", "display"); } if ($title != "") { return "{$prefix}{$separator}{$title}"; } else { return $prefix; } }