本文整理汇总了PHP中category_description函数的典型用法代码示例。如果您正苦于以下问题:PHP category_description函数的具体用法?PHP category_description怎么用?PHP category_description使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了category_description函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calibrefx_meta_description
/**
* 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);
}
示例2: description
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);
}
}
示例3: register_meta_tags
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";
});
}
示例4: get_desc
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));
}
示例5: kkthemes_archive_title
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
}
示例6: lo_description
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";
}
示例7: active_nav_class
function active_nav_class($classes, $item)
{
if (is_single() && $item->title == category_description()) {
$classes[] = "active";
$classes[] = "current-menu-item";
}
return $classes;
}
示例8: sp_get_category_description
function sp_get_category_description()
{
global $post;
$desc = category_description();
if (is_object($desc)) {
return '';
}
return strip_tags($desc);
}
示例9: smamo_add_metas
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 . '">';
}
}
示例10: getResource
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);
}
示例11: gabfire_catNameDesc
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
}
}
示例12: category_tagline
/**
* 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;
}
}
示例13: the_meta_descr
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;
}
}
示例14: fifu_cat_add_social_tags
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';
}
}
示例15: rolo_pageheader
/**
* 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>';
}
}