Beispiel #1
0
/**
 * 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);
}
Beispiel #2
0
/**
 * limits the output for title to $max_char characters,
 * and appends an ellipses to the end.
 */
function get_the_title_limit($max_char, $post_id = 0)
{
    $title = get_the_title($post_id);
    // Truncate $content to $max_char
    if (strlen($title) > $max_char) {
        $title = calibrefx_truncate_phrase($title, $max_char);
        $output = sprintf('%s...', $title);
    } else {
        $output = sprintf('%s', $title);
    }
    return apply_filters('get_the_title_limit', $output, $title, $max_char);
}