function wtf_canonical_link() { if (is_singular() && ($page_id = wtf_get_object_id())) { echo '<link rel="canonical" href="' . get_permalink($page_id) . '">' . "\n"; } }
function wtf_body_custom($class) { global $post; if (is_search()) { $page_class = 'page-search '; } elseif (is_category()) { $page_class = 'page-category '; } elseif (is_tag()) { $page_class = 'page-tag '; } elseif (is_archive()) { $page_class = 'page-archive '; } elseif ($object_id = wtf_get_object_id()) { $page_id = $post->post_name; $page_class = 'page-' . $page_id . ' '; } elseif (is_404()) { $page_id = '404'; $page_class = 'page-404 '; } else { // Silence is golden. } $post_type = get_post_type(); $class .= ' ' . $post_type; if (is_single()) { $class .= ' single'; } if (is_page()) { $ancestors = get_post_ancestors($post); $ancestors = array_reverse($ancestors); $parent = $ancestors[0]; $parent = get_page($parent); $parent_slug = $parent->post_name; $class .= ' parent-' . $parent_slug; } echo '<body id="' . $page_id . '" class="' . (isset($page_class) ? $page_class : '') . $class . '">'; }