/** * Output description * * @return string $description */ function calibrefx_meta_description() { global $post, $wp_query, $wp_locale; $desc = ''; if (is_home() || is_front_page()) { $desc = get_bloginfo('description'); } elseif (is_singular()) { $desc = calibrefx_truncate_phrase($post->post_content, calibrefx_get_option('content_archive_limit')); } elseif (is_archive()) { if (is_category()) { $desc = category_description(get_query_var('cat')); } elseif (is_tax()) { $term = $wp_query->get_queried_object(); $desc = term_description($term->term_id, $term->taxonomy); } elseif (is_year()) { $desc = __('All posts in ', 'calibrefx') . get_query_var('year'); } elseif (is_month()) { $desc = __('All Posts in ', 'calibrefx') . $wp_locale->get_month(get_query_var('monthnum')) . ' ' . get_query_var('year'); } elseif (is_day()) { $desc = __('All Posts in ', 'calibrefx') . get_query_var('day') . ' ' . $wp_locale->get_month(get_query_var('monthnum')) . ' ' . get_query_var('year'); } elseif (is_author()) { $desc = get_user_meta($wp_query->queried_object->ID, 'intro_text', true); } elseif (is_post_type_archive()) { $post_type = $wp_query->get_queried_object(); $desc = $post_type->description; } } elseif (is_404()) { $desc = __('Page not found ', 'calibrefx'); } $desc = str_replace(array('<p>', '</p>'), array('', ''), $desc); $desc = htmlentities($desc); return apply_filters('calibrefx_meta_description', $desc); }
function description() { if (is_home() || is_front_page()) { echo trim(of_get_option('site_description')); } elseif (is_category()) { $description = strip_tags(category_description()); echo trim($description); } elseif (is_single()) { if (get_the_excerpt()) { echo get_the_excerpt(); } else { global $post; $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content)))); echo mb_substr($description, 0, 220, 'utf-8'); } } elseif (is_search()) { echo '“'; the_search_query(); echo '”为您找到结果 '; global $wp_query; echo $wp_query->found_posts; echo ' 个'; } elseif (is_tag()) { $description = strip_tags(tag_description()); echo trim($description); } else { $description = strip_tags(term_description()); echo trim($description); } }
public function register_meta_tags() { add_action('wp_head', function () { if (is_singular() && false == post_password_required()) { if ('' == ($description = get_the_excerpt())) { $description = wp_trim_words(esc_html(strip_shortcodes(get_the_content())), 20, '...'); } } elseif (is_category() && '' != category_description()) { $description = category_description(); } elseif (is_tag() && '' != term_description()) { $description = term_description(); } else { $description = get_bloginfo('description'); } $description = esc_attr($description); echo "<meta name=\"description\" content=\"{$description}\" />\n"; echo "<meta name=\"og:description\" content=\"{$description}\" />\n"; if (is_singular() && false == post_password_required() && has_post_thumbnail()) { list($image, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id(), 'facebook'); } else { $image = apply_filters('', $this->get_theme_assets_url() . '/images/logo-fb.png'); } $image = esc_url($image); echo "<meta name=\"og:image\" content=\"{$image}\" />\n"; echo "<meta name=\"twitter:image\" content=\"{$image}\" />\n"; }); }
function get_desc() { if (is_404()) { $desc = __("Sorry, but the page you were trying to view does not exist. \n\nIt looks like this was the result of either a mistyped address or an out-of-date link.", 'skrollr'); } else { if (is_category()) { $desc = category_description(); } else { if (is_tag()) { $desc = tag_description(); } else { if (is_search()) { global $wp_query; if ($wp_query->found_posts == 0) { $desc = __('Nothing found', 'skrollr'); } else { $desc = sprintf(_n('One post found.', '%d posts found', $wp_query->found_posts, 'skrollr'), $wp_query->found_posts); } } else { $desc = get_theme_mod('metadesc'); } } } } return wpautop(esc_html($desc)); }
function kkthemes_archive_title() { $tag_style = ''; $header_image = get_header_image(); if (!empty($header_image)) { $tag_style = 'background-image: url(' . esc_url($header_image) . ');'; } ?> <div class="uk-panel uk-panel-box uk-panel-space uk-text-large uk-text-center tm-branded-panel uk-margin-large-bottom" style="<?php echo $tag_style; ?> "> <h1 class="uk-article-title" itemprop="headline"> <?php single_cat_title('') || post_type_archive_title(''); ?> </h1> <?php if (is_featured_item()) { $post_type = get_post_type(); echo '<p>' . get_post_type_object($post_type)->description . '</p>'; } else { echo category_description(); } ?> </div> <?php }
function lo_description() { global $s, $post; $description = ''; $blog_name = get_bloginfo('name'); if (is_singular()) { $ID = $post->ID; $title = $post->post_title; $author = $post->post_author; $user_info = get_userdata($author); $post_author = $user_info->display_name; if (!get_post_meta($ID, "meta-description", true)) { $description = $title . ' - 作者: ' . $post_author . ',首发于' . $blog_name; } else { $description = get_post_meta($ID, "meta-description", true); } } elseif (is_home()) { $description = lo_opt('index_description'); } elseif (is_tag()) { $description = single_tag_title('', false) . " - " . trim(strip_tags(tag_description())); } elseif (is_category()) { $description = single_cat_title('', false) . " - " . trim(strip_tags(category_description())); } elseif (is_archive()) { $description = $blog_name . "'" . trim(wp_title('', false)) . "'"; } elseif (is_search()) { $description = $blog_name . ": '" . esc_html($s, 1) . "' 的搜索結果"; } else { $description = $blog_name . "'" . trim(wp_title('', false)) . "'"; } $description = mb_substr($description, 0, 220, 'utf-8'); echo "<meta name=\"description\" content=\"{$description}\">\n"; }
function active_nav_class($classes, $item) { if (is_single() && $item->title == category_description()) { $classes[] = "active"; $classes[] = "current-menu-item"; } return $classes; }
function sp_get_category_description() { global $post; $desc = category_description(); if (is_object($desc)) { return ''; } return strip_tags($desc); }
function smamo_add_metas() { global $post; if ($post) { // Billede $meta_img = false; $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large'); if ($image_url && isset($image_url[0])) { $meta_img = $image_url[0]; } if (!$meta_img) { $meta_img = smamo_inner_img($post->ID); } if (!$meta_img || is_home() || is_front_page()) { $meta_img = get_header_image(); } // Beskrivelse $meta_description = wp_trim_words(wp_strip_all_tags($post->post_excerpt), $num_words = 30, $more = ' ...'); if (!$meta_description) { $meta_description = wp_trim_words(wp_strip_all_tags($post->post_content), $num_words = 30, $more = ' ...'); } if (!$meta_description) { if (is_archive() || is_category()) { $meta_description = wp_trim_words(wp_strip_all_tags(category_description()), $num_words = 30, $more = ' ...'); } } if (!$meta_description || is_home() || is_front_page()) { $meta_description = wp_trim_words(get_bloginfo('description'), $num_words = 30, $more = ' ...'); } // Link $meta_url = get_the_permalink(); if (!$meta_url || is_home() || is_front_page()) { $meta_url = get_bloginfo('url'); } // Type $meta_type = 'article'; if (is_archive()) { $meta_type = 'archive'; } elseif (is_home() || is_front_page()) { $meta_type = 'website'; } echo '<meta itemprop="name" content="' . $post->post_title . '">'; echo '<meta property="og:title" content="' . $post->post_title . '">'; echo '<meta property="og:site_name" content="' . get_bloginfo('title') . '">'; if ($meta_description) { echo '<meta name="description" content="' . $meta_description . '">'; echo '<meta itemprop="description" content="' . $meta_description . '">'; echo '<meta property="og:description" content="' . $meta_description . '">'; } if ($meta_img) { echo '<meta itemprop="image" content="' . $meta_img . '">'; echo '<meta property="og:image" content="' . $meta_img . '">'; } echo '<meta property="og:type" content="' . $meta_type . '">'; echo '<meta property="og:url" content="' . $meta_url . '">'; } }
public function getResource($pretty = false) { $hasPart = array(); while (have_posts()) { the_post(); $hasPart[] = array('@type' => 'BlogPosting', 'headline' => get_the_title(), 'url' => get_the_permalink(), 'datePublished' => get_the_date('Y-m-d'), 'dateModified' => get_the_modified_date('Y-m-d'), 'mainEntityOfPage' => get_the_permalink(), 'author' => $this->getAuthor(), 'publisher' => $this->getPublisher(), 'image' => $this->getImage(), 'keywords' => $this->getTags(), 'commentCount' => get_comments_number(), 'comment' => $this->getComments()); } $this->schema = array('@context' => 'http://schema.org/', '@type' => $this->schemaType, 'headline' => single_cat_title('', false) . " Category", 'description' => category_description(), 'url' => get_category_link(get_query_var('cat')), 'hasPart' => $hasPart); return $this->toJson($pretty); }
function gabfire_catNameDesc() { if (is_category()) { ?> <section class="row"> <div class="col-md-12"> <div class="post-lead"> <?php if (is_category()) { ?> <h1><?php single_cat_title(); ?> </h1> <?php echo category_description(); ?> <?php } else { ?> <h1 class="post-title"><?php single_tag_title(); ?> </h1> <?php echo tag_description(); ?> <?php } ?> </div> </div> </section><?php } elseif (is_search()) { ?> <section class="row archive"> <div class="col-md-12"> <div class="post-lead"> <h1><i class='fa fa-search'></i> <?php echo get_search_query(); ?> </h1> <?php $search_query = get_search_query(); ?> <p><?php printf(esc_attr__('Search results for %1$s', 'gabfire'), $search_query); ?> </p> </div> </div> </section><?php } }
/** * Get the tagline for a category. * * The tagline is parsed from Wordpress's "description" field for categories. It * consists of all text found after the first colon in the description. If no * colon is found, it returns the whole string. If the given category ID does * not exist, it returns an empty string. * * @param $cat_ID (Int) The category ID for which to get the tagline. * * @return (String) The tagline for the given category, or the empty string on * failure. */ function category_tagline($cat_ID) { $cat_description = strip_tags(category_description($cat_ID)); $first_colon_index = strpos($cat_description, "\n"); // If a colon was found, return the string after that point. If no colon was // found, return the whole string. if ($first_colon_index !== false) { return substr($cat_description, $first_colon_index + 1); } else { return $cat_description; } }
function the_meta_descr() { global $post; if (is_category()) { $meta_descr = category_description(); } else { $meta_descr = $post->post_content; } if (isset($meta_descr)) { echo '<meta name="description" content="' . htmlspecialchars(strip_tags($meta_descr)) . '" />' . PHP_EOL; } }
function fifu_cat_add_social_tags() { $url = fifu_cat_get_url(); $title = single_cat_title('', false); $term_id = fifu_cat_get_term_id(); if ($term_id) { $description = wp_strip_all_tags(category_description($term_id)); } if ($url) { include 'html/social.html'; } }
/** * Shows appropriate title for each page * * @since 1.2 */ function rolo_pageheader() { if (is_single()) { $pagetitle = '<h2 class="page-title">' . __(get_the_term_list($post->ID, 'type', ' ', ', ', ': '), 'rolopress') . __(get_the_title(), 'rolopress') . "</h2>\n"; } elseif (is_page()) { $pagetitle = '<h2 class="page-title page">' . __(get_the_title(), 'rolopress') . "</h2>\n"; } elseif (is_404()) { $pagetitle = '<h2 class="page-title 404">' . __('Not Found', 'rolopress') . "</h2>\n"; } elseif (is_home()) { $pagetitle = '<h2 class="page-title home">' . __('All Items', 'rolopress') . "</h2>\n"; } elseif (is_search()) { $pagetitle = '<h2 class="page-title search">' . __('Search Results for: ', 'rolopress') . '"' . get_search_query() . '"' . "</h2>\n"; } elseif (is_category()) { $current_category = single_cat_title("", false); $pagedesc = category_description(); $pagetitle = '<h2 class="page-title category">' . __('Items Categorized As: ', 'rolopress') . '"' . $current_category . '"' . "</h2>\n"; } elseif (is_tag()) { $current_tag = single_tag_title("", false); $pagedesc = tag_description(); $pagetitle = '<h2 class="page-title tag">' . __('Items Tagged As: ', 'rolopress') . '"' . $current_tag . '"' . "</h2>\n"; } elseif (is_tax()) { global $term; $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $pagedesc = $term->description; $pagetitle = '<h2 class="page-title taxonomy">' . __($term->name, 'rolopress') . __(' List', 'rolopress') . "</h2>\n"; } elseif (is_author()) { global $wp_query; $curauth = $wp_query->get_queried_object(); // get the authors name $pagetitle = '<h2 class="page-title author">' . __('Owned by: ', 'rolopress') . $curauth->display_name . "</h2>\n"; } elseif (is_archive()) { if (is_day()) { $pagetitle = '<h2 class="page-title day">' . __('Items Created On: ', 'rolopress') . get_the_time(get_option('date_format')) . "</h2>\n"; } elseif (is_month()) { $pagetitle = '<h2 class="page-title month">' . __('Items Created In: ', 'rolopress') . get_the_time('F Y') . "</h2>\n"; } elseif (is_year()) { $pagetitle = '<h2 class="page-title year">' . __('Items Created In: ', 'rolopress') . get_the_time('Y') . "</h2>\n"; } } else { $pagetitle = '<h2 class="page-title page">' . __(get_the_title(), 'rolopress') . "</h2>\n"; } // show the page title echo $pagetitle; // show a description if set if (!empty($pagedesc)) { echo '<div class="archive-meta">' . $pagedesc . '</div>'; } }
/** * Category Description * * @since 1.0.4 */ function dslc_sc_category_description($atts, $content) { extract(shortcode_atts(array('category_ID' => false), $atts)); // If category ID not supplied, get current category if (!$category_ID) { $category_ID = get_query_var('cat'); } // Get category description $category_description = category_description($category_ID); // Placeholder description if (!is_category() && empty($category_description) && dslc_is_editor_active('access')) { $category_description = __('Category description will be shown here.', 'live-composer-page-builder'); } // Return category description return $category_description; }
function mytheme_description() { global $post; if (is_front_page()) { $description = get_bloginfo('description'); } elseif (is_archive()) { $description = category_description(); } elseif (is_tag()) { $description = tag_description(); } else { setup_postdata($post); $content = get_the_excerpt(); $author = get_userdata($post->post_author)->user_nicename; $description = htmlspecialchars($content); } echo '<meta name="description" content="' . strip_tags($description) . '">' . "\n"; }
function get_image_noecho($id, $post) { $category = get_the_category($id); $countCategory = count($category); $categoryid = mt_rand(0, $countCategory - 1); $filename = category_description($category[$categoryid]->cat_ID); $filename = preg_replace("/<p>/", "", $filename); $filename = preg_replace("/<\\/p>/", "", $filename); $filename = "tumb150_" . $filename; $first_img = ''; $output = preg_match("/<img src=\"(http:\\/\\/[_a-z0-9:\\/\\.-]+\\/([_a-z-0-9]+\\.[jpegngifbmJPEGIFNGBM]{3,4}))\">/u", $post, $matches); if (empty($matches[1])) { $first_img = get_template_directory_uri() . "/img/{$filename}"; } else { $first_img = "http://omoro.top/wp-content/uploads/tumb150_{$matches[2]}"; // $first_img = $matches[1]; } return $first_img; }
function description_tag() { if (is_home()) { bloginfo('description'); } elseif (is_single() || is_page()) { $description = get_post_meta(get_the_ID(), 'meta-description', true); if ($description !== '' || !empty($description)) { echo $description; } else { $myExcerpt = get_the_excerpt(); $tags = array("<p>", "</p>"); $myExcerpt = str_replace($tags, "", $myExcerpt); echo $myExcerpt; } } elseif (is_category() || is_archive()) { echo category_description(); } else { bloginfo('description'); } }
/** * Meta description */ function mantra_seo_description() { global $mantra_options; foreach ($mantra_options as $key => $value) { ${"{$key}"} = $value; } if (is_home() && $mantra_seo_home_desc || is_page_template('template-blog.php') && $mantra_seo_home_desc) { echo PHP_EOL . '<meta name="description" content="'; echo $mantra_seo_home_desc; echo '" />'; } else { if ((is_single() || is_page()) && !is_404()) { if ($mantra_seo_gen_desc == "Auto") { global $post; $content_post = get_post($post->ID); $content = strip_shortcodes($content_post->post_content); $content = preg_replace(array('/\\s{2,}/', '/[\\t\\n]/'), ' ', $content); $content = strip_tags($content); $content = str_replace('"', '', $content); $content = preg_replace('/((\\w+\\W+\'*){' . 33 . '}(\\w+))(.*)/', '${1}', $content); } else { if ($mantra_seo_gen_desc == "Manual") { global $post, $mantra_meta_box_description; $content = get_post_meta($post->ID, 'SEOdescription_value', true); } } echo PHP_EOL . '<meta name="description" content="'; echo $content; echo '" />'; } else { if (is_category() && category_description() != "") { echo PHP_EOL . '<meta name="description" content="'; echo trim(strip_tags(category_description())); echo '" />'; } } } }
rewind_posts(); } elseif (is_day()) { printf(__('Daily Archives: %s', 'outlines'), '<span>' . get_the_date() . '</span>'); } elseif (is_month()) { printf(__('Monthly Archives: %s', 'outlines'), '<span>' . get_the_date('F Y') . '</span>'); } elseif (is_year()) { printf(__('Yearly Archives: %s', 'outlines'), '<span>' . get_the_date('Y') . '</span>'); } else { _e('Archives', 'outlines'); } ?> </h1> <?php if (is_category()) { // show an optional category description $category_description = category_description(); if (!empty($category_description)) { echo apply_filters('category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>'); } } elseif (is_tag()) { // show an optional tag description $tag_description = tag_description(); if (!empty($tag_description)) { echo apply_filters('tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>'); } } ?> </header><!-- .page-header --> <?php outlines_content_nav('nav-above');
echo $content_css; ?> "> <?php if (category_description()) { ?> <div id="post-<?php the_ID(); ?> " <?php post_class('post'); ?> > <div class="post-content"> <?php echo category_description(); ?> </div> </div> <?php } ?> <div class="portfolio-wrapper"> <?php while (have_posts()) { the_post(); if (has_post_thumbnail()) { ?> <?php $item_classes = ''; $item_cats = get_the_terms($post->ID, 'portfolio_category');
/** * @package WordPress * @subpackage Beach */ get_header(); ?> <section id="primary"> <div id="content" role="main"> <header class="page-header"> <h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'beach' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1> <?php $categorydesc = category_description(); if ( ! empty( $categorydesc ) ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . $categorydesc . '</div>' ); ?> </header> <?php beach_content_nav( 'nav-above' ); ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php beach_content_nav( 'nav-below' ); ?> </div><!-- #content -->
get_header(); ?> <div id="content_wrap"> <div class="content" id="content"> <div class="archive-header"> <h1><a href="<?php echo get_category_link(get_cat_ID(single_cat_title('', false))); ?> "> <?php single_cat_title(); ?> </a></h1> <?php if (category_description()) { echo '<div class="archive-header-info">' . category_description() . '</div>'; } ?> </div> <?php include 'modules/excerpt.php'; ?> </div> <?php get_sidebar(); ?> </div> <?php get_footer();
function elegant_description() { global $shortname; #homepage descriptions if (is_home() && get_option($shortname . '_seo_home_description') == 'on') { echo '<meta name="description" content="' . get_option($shortname . '_seo_home_descriptiontext') . '" />'; } #single page descriptions global $wp_query; $postid = $wp_query->post->ID; $key2 = get_option($shortname . '_seo_single_field_description'); $exists = get_post_meta($postid, '' . $key2 . '', true); if (get_option($shortname . '_seo_single_description') == 'on' && $exists !== '') { if (is_single() || is_page()) { echo '<meta name="description" content="' . $exists . '" />'; } } #index descriptions remove_filter('term_description', 'wpautop'); $cat = get_query_var('cat'); $exists2 = category_description($cat); if ($exists2 !== '' && get_option($shortname . '_seo_index_description') == 'on') { if (is_category()) { echo '<meta name="description" content="' . $exists2 . '" />'; } } if (is_archive() && get_option($shortname . '_seo_index_description') == 'on') { echo '<meta name="description" content="Currently viewing archives from' . wp_title('', false, '') . '" />'; } if (is_search() && get_option($shortname . '_seo_index_description') == 'on') { echo '<meta name="description" content="' . wp_title('', false, '') . '" />'; } }
function rewrite_title($header) { global $wp_query; if (!$wp_query) { $header .= "<!-- no wp_query found! -->\n"; return $header; } $post = $wp_query->get_queried_object(); // the_search_query() is not suitable, it cannot just return global $s; // simple tagging support global $STagging; if (is_home()) { $title = $this->internationalize(get_option('aiosp_home_title')); if (empty($title)) { $title = $this->internationalize(get_option('blogname')); } $title = $this->paged_title($title); $header = $this->replace_title($header, $title); } else { if (is_single()) { // we're not in the loop :( $authordata = get_userdata($post->post_author); $categories = get_the_category(); $category = ''; if (count($categories) > 0) { $category = $categories[0]->cat_name; } $title = $this->internationalize(get_post_meta($post->ID, "title", true)); if (!$title) { $title = $this->internationalize(get_post_meta($post->ID, "title_tag", true)); if (!$title) { $title = $this->internationalize(wp_title('', false)); } } $title_format = get_option('aiosp_post_title_format'); $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title); $new_title = str_replace('%post_title%', $title, $new_title); $new_title = str_replace('%category%', $category, $new_title); $new_title = str_replace('%category_title%', $category, $new_title); $new_title = str_replace('%post_author_login%', $authordata->user_login, $new_title); $new_title = str_replace('%post_author_nicename%', $authordata->user_nicename, $new_title); $new_title = str_replace('%post_author_firstname%', ucwords($authordata->first_name), $new_title); $new_title = str_replace('%post_author_lastname%', ucwords($authordata->last_name), $new_title); $title = $new_title; $title = trim($title); $header = $this->replace_title($header, $title); } else { if (is_search() && isset($s) && !empty($s)) { if (function_exists('attribute_escape')) { $search = attribute_escape(stripcslashes($s)); } else { $search = wp_specialchars(stripcslashes($s), true); } $search = $this->capitalize($search); $title_format = get_option('aiosp_search_title_format'); $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title); $title = str_replace('%search%', $search, $title); $header = $this->replace_title($header, $title); } else { if (is_category() && !is_feed()) { $category_description = $this->internationalize(category_description()); $category_name = ucwords($this->internationalize(single_cat_title('', false))); $title_format = get_option('aiosp_category_title_format'); $title = str_replace('%category_title%', $category_name, $title_format); $title = str_replace('%category_description%', $category_description, $title); $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title); $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title); $title = $this->paged_title($title); $header = $this->replace_title($header, $title); } else { if (is_page()) { // we're not in the loop :( $authordata = get_userdata($post->post_author); if ($this->is_static_front_page()) { if ($this->internationalize(get_option('aiosp_home_title'))) { $header = $this->replace_title($header, $this->internationalize(get_option('aiosp_home_title'))); } } else { $title = $this->internationalize(get_post_meta($post->ID, "title", true)); if (!$title) { $title = $this->internationalize(wp_title('', false)); } $title_format = get_option('aiosp_page_title_format'); $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title); $new_title = str_replace('%page_title%', $title, $new_title); $new_title = str_replace('%page_author_login%', $authordata->user_login, $new_title); $new_title = str_replace('%page_author_nicename%', $authordata->user_nicename, $new_title); $new_title = str_replace('%page_author_firstname%', ucwords($authordata->first_name), $new_title); $new_title = str_replace('%page_author_lastname%', ucwords($authordata->last_name), $new_title); $title = trim($new_title); $header = $this->replace_title($header, $title); } } else { if (function_exists('is_tag') && is_tag()) { global $utw; if ($utw) { $tags = $utw->GetCurrentTagSet(); $tag = $tags[0]->tag; $tag = str_replace('-', ' ', $tag); } else { // wordpress > 2.3 $tag = $this->internationalize(wp_title('', false)); } if ($tag) { $tag = $this->capitalize($tag); $title_format = get_option('aiosp_tag_title_format'); $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title); $title = str_replace('%tag%', $tag, $title); $title = $this->paged_title($title); $header = $this->replace_title($header, $title); } } else { if (isset($STagging) && $STagging->is_tag_view()) { // simple tagging support $tag = $STagging->search_tag; if ($tag) { $tag = $this->capitalize($tag); $title_format = get_option('aiosp_tag_title_format'); $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title); $title = str_replace('%tag%', $tag, $title); $title = $this->paged_title($title); $header = $this->replace_title($header, $title); } } else { if (is_archive()) { $date = $this->internationalize(wp_title('', false)); $title_format = get_option('aiosp_archive_title_format'); $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title); $new_title = str_replace('%date%', $date, $new_title); $title = trim($new_title); $title = $this->paged_title($title); $header = $this->replace_title($header, $title); } else { if (is_404()) { $title_format = get_option('aiosp_404_title_format'); $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format); $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title); $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title); $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title); $header = $this->replace_title($header, $new_title); } } } } } } } } } return $header; }
function custom_meta_description() { global $post; function prepare_content($content) { $content = ucfirst(trim(strip_tags($content))); // Remove shortcodes, but leave content. $content = preg_replace('/\\[.*?\\]/', '', $content); // Remove new lines. $content = preg_replace('~[\\r\\n]+~', ' ', $content); // Removes everything except these characters. $content = preg_replace('/[^a-zA-Z0-9_.\\-,\\s]/', '', $content); // Remove extra spaces. $content = preg_replace('/\\s+/', ' ', $content); // Shortens length. May not be needed. Testing with Google indexing. if (strlen($content) > 4000) { $content = substr($content, 0, 4000) . '...'; } return $content; } if (is_single()) { if ($post->post_type === 'work') { $description = prepare_content(get_post_meta(get_the_ID(), 'slide_1_description', true)); } elseif ($post->post_type === 'blog') { if (have_posts()) { while (have_posts()) { the_post(); $description = prepare_content(get_the_content()); } } } } elseif (is_home() || is_page()) { $description = get_bloginfo('description'); } elseif (is_category()) { $description = prepare_content(category_description()); } elseif (is_archive()) { $description = 'Archive of all ' . $post->post_type . ' posts.'; } elseif (is_tag()) { $description = 'Archive of all posts with the tag "' . prepare_content(single_tag_title('', FALSE)) . '".'; } if (empty($description)) { $description = get_bloginfo('description'); } echo $description; }
<?php } elseif (is_singular('post')) { get_template_part('parts/entry-head'); ?> <?php } elseif (is_category()) { ?> <h1> <?php echo single_cat_title(); ?> </h1> <?php $category_description = strip_tags(category_description()); if ($category_description) { ?> <p class="intro"> <?php echo $category_description; ?> </p> <?php } ?> <?php } elseif (is_archive()) { ?> <h1>
?> <?php //query_posts(array('posts_per_page = 10')); ?> <?php if (have_posts()) { ?> <section id="main-section" class="section section-index"> <div class="section-head"> <h2 class="section-title ui header">Blog</h2> <div class="section-description"> <?php print category_description(); ?> </div> </div> <div class="ui dividing header"></div> <div class="section-body"> <?php while (have_posts()) { the_post(); ?> <?php
function elegant_description() { // Don't use ePanel SEO if WordPress SEO or All In One SEO Pack plugins are active if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) { return; } global $shortname, $themename; #homepage descriptions if (et_get_option($shortname . '_seo_home_description') == 'on' && ((is_home() || is_front_page()) && !elegant_is_blog_posts_page())) { echo '<meta name="description" content="' . esc_attr(et_get_option($shortname . '_seo_home_descriptiontext')) . '" />'; } #single page descriptions if (et_get_option($shortname . '_seo_single_description') == 'on' && (is_single() || is_page() || elegant_is_blog_posts_page())) { global $wp_query; if (isset($wp_query->post->ID) || elegant_is_blog_posts_page()) { $postid = elegant_is_blog_posts_page() ? intval(get_option('page_for_posts')) : $wp_query->post->ID; } $key2 = et_get_option($shortname . '_seo_single_field_description'); if (isset($postid)) { $exists = get_post_meta($postid, '' . $key2 . '', true); } if ($exists !== '') { echo '<meta name="description" content="' . esc_attr($exists) . '" />'; } } #index descriptions $seo_index_description = et_get_option($shortname . '_seo_index_description'); if ($seo_index_description == 'on') { $description_added = false; if (is_category()) { remove_filter('term_description', 'wpautop'); $cat = get_query_var('cat'); $exists2 = category_description($cat); if ($exists2 !== '') { echo '<meta name="description" content="' . esc_attr($exists2) . '" />'; $description_added = true; } } if (is_archive() && !$description_added) { printf('<meta name="description" content="%1$s" />', esc_attr(sprintf(__('Currently viewing archives from %1$s', $themename), wp_title('', false, '')))); $description_added = true; } if (is_search() && !$description_added) { echo '<meta name="description" content="' . esc_attr(wp_title('', false, '')) . '" />'; $description_added = true; } } }