サポート » 使い方全般 » 月別アーカイブページの title 要素の英語表示方法

  • はじめましてRMVPと申します。
    いつもお世話になっております。

    月別アーカイブページの title 要素の英語表示にしたく、下記のプラグインをインストールしたのですが、カスタマイズ方法がわからずこの度、ご投稿させていただきました。

    プラグイン
    wp-title

    今現在、プラグインを有効後、下記のような表示となります。

    月別の場合
    「2013 February」

    日別の場合(例:2月1日)
    「2013 February 01」

    上記の表記を下記のように変更したいのですが、どのようにすれば宜しいでしょうか?

    ・希望の表記

    月別の場合
    「Feb 2013」又は「February 2013」

    日別の場合(例:2月1日)
    「Feb 1 2013」又は「February 1 2013」

    プラグインのPHPは下記の通りとなります。

    <?php
    /*
    Plugin Name: wp-title
    Plugin URI: http://www.koikikukan.com/2008/12/10-005555.php
    Description: This plugin provide get_title function instead of wp_title.
    Version: 0.1
    Author: Yujiro Araki
    Author URI: http://www.koikikukan.com/
    */

    load_plugin_textdomain(‘Title’,’wp-content/plugins/wp-title’);

    function get_title($sep = ‘»’, $display = true, $seplocation = ”) {
    global $wpdb, $wp_locale, $wp_query;

    $cat = get_query_var(‘cat’);
    $tag = get_query_var(‘tag_id’);
    $category_name = get_query_var(‘category_name’);
    $author = get_query_var(‘author’);
    $author_name = get_query_var(‘author_name’);
    $m = get_query_var(‘m’);
    $year = get_query_var(‘year’);
    $monthnum = get_query_var(‘monthnum’);
    $day = get_query_var(‘day’);
    $title = ”;

    // If there’s a category
    if ( !empty($cat) ) {
    // category exclusion
    if ( !stristr($cat,’-‘) )
    $title = apply_filters(‘single_cat_title’, get_the_category_by_ID($cat));
    } elseif ( !empty($category_name) ) {
    if ( stristr($category_name,’/’) ) {
    $category_name = explode(‘/’,$category_name);
    if ( $category_name[count($category_name)-1] )
    $category_name = $category_name[count($category_name)-1]; // no trailing slash
    else
    $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
    }
    $cat = get_term_by(‘slug’, $category_name, ‘category’, OBJECT, ‘display’);
    if ( $cat )
    $title = apply_filters(‘single_cat_title’, $cat->name);
    }

    if ( !empty($tag) ) {
    $tag = get_term($tag, ‘post_tag’, OBJECT, ‘display’);
    if ( is_wp_error( $tag ) )
    return $tag;
    if ( ! empty($tag->name) )
    $title = apply_filters(‘single_tag_title’, $tag->name);
    }

    // If there’s an author
    if ( !empty($author) ) {
    $title = get_userdata($author);
    $title = $title->display_name;
    }
    if ( !empty($author_name) ) {
    // We do a direct query here because we don’t cache by nicename.
    $title = $wpdb->get_var($wpdb->prepare(“SELECT display_name FROM $wpdb->users WHERE user_nicename = %s”, $author_name));
    }

    // If there’s a month(without separator)
    if ( !empty($m) ) {
    $my_year = substr($m, 0, 4) . __(‘Year’,’Title’) . ” “;
    $my_month = $wp_locale->get_month(substr($m, 4, 2));
    $my_day = intval(substr($m, 6, 2));
    $title = “$my_year” . ($my_month ? ” $my_month” : “”) . ($my_day ? ” $my_day” . __(‘Day’,’Title’) : “”);
    }
    // If there’s a month(with separator)
    // if ( !empty($m) ) {
    // $my_year = substr($m, 0, 4) . __(‘Year’,’Title’) . ” “;
    // $my_month = $wp_locale->get_month(substr($m, 4, 2));
    // $my_day = intval(substr($m, 6, 2));
    // $title = “$my_year” . ($my_month ? “$sep $my_month” : “”) . ($my_day ? ” $sep $my_day” . __(‘Day’,’Title’) : “”);
    // }
    // If there’s a month(original)
    // if ( !empty($m) ) {
    // $my_year = substr($m, 0, 4);
    // $my_month = $wp_locale->get_month(substr($m, 4, 2));
    // $my_day = intval(substr($m, 6, 2));
    // $title = “$my_year” . ($my_month ? “$sep $my_month” : “”) . ($my_day ? “$sep $my_day” : “”);
    // }

    if ( !empty($year) ) {
    $title = $year;
    if ( !empty($monthnum) )
    $title .= ” $sep ” . $wp_locale->get_month($monthnum);
    if ( !empty($day) )
    $title .= ” $sep ” . zeroise($day, 2);
    }

    // If there is a post
    if ( is_single() || is_page() ) {
    $post = $wp_query->get_queried_object();
    $title = strip_tags( apply_filters( ‘single_post_title’, $post->post_title ) );
    }

    // If there’s a taxonomy
    if ( is_tax() ) {
    $taxonomy = get_query_var( ‘taxonomy’ );
    $tax = get_taxonomy( $taxonomy );
    $tax = $tax->label;
    $term = $wp_query->get_queried_object();
    $term = $term->name;
    if ( ‘right’ == $seplocation )
    $title = “$term $sep $tax”;
    else
    $title = “$tax $sep $term”;
    }

    $prefix = ”;
    if ( !empty($title) )
    $prefix = ” $sep “;

    // Determines position of the separator
    if ( ‘right’ == $seplocation )
    $title = $title . $prefix;
    else
    $title = $prefix . $title;

    $title = apply_filters(‘wp_title’, $title, $sep);

    // Send it out
    if ( $display )
    echo $title;
    else
    return $title;

    }

    ?>

    皆様のアドバイス等いただけましたら幸いでございます。
    大変御迷惑お手数をおかけ致しまして誠に申し訳ございません。

    何卒宜しくお願い申し上げます。

1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「月別アーカイブページの title 要素の英語表示方法」には新たに返信することはできません。