PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/titles.php

https://github.com/sfradel/roots
PHP | 37 lines | 34 code | 0 blank | 3 comment | 6 complexity | cb90d5a1bc136f9a4825bd8a923ac103 MD5 | raw file
  1. <?php
  2. /**
  3. * Page titles
  4. */
  5. function roots_title() {
  6. if (is_home()) {
  7. if (get_option('page_for_posts', true)) {
  8. echo get_the_title(get_option('page_for_posts', true));
  9. } else {
  10. _e('Latest Posts', 'roots');
  11. }
  12. } elseif (is_archive()) {
  13. $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
  14. if ($term) {
  15. echo $term->name;
  16. } elseif (is_post_type_archive()) {
  17. echo get_queried_object()->labels->name;
  18. } elseif (is_day()) {
  19. printf(__('Daily Archives: %s', 'roots'), get_the_date());
  20. } elseif (is_month()) {
  21. printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
  22. } elseif (is_year()) {
  23. printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
  24. } elseif (is_author()) {
  25. $author = get_queried_object();
  26. printf(__('Author Archives: %s', 'roots'), $author->display_name);
  27. } else {
  28. single_cat_title();
  29. }
  30. } elseif (is_search()) {
  31. printf(__('Search Results for %s', 'roots'), get_search_query());
  32. } elseif (is_404()) {
  33. _e('Not Found', 'roots');
  34. } else {
  35. the_title();
  36. }
  37. }