フォーラムへの返信

6件の返信を表示中 - 1 - 6件目 (全6件中)
  • フォーラム: プラグイン
    返信が含まれるトピック: WP-PostViewsでカテゴリとタグの表示
    トピック投稿者 bumsos

    (@bumsos)

    201〜212行目の所に

    $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
    $thumbnail = get_the_post_thumbnail($post->ID, array(210,140), array(‘alt’=>$post_title, ‘title’=>$post_title));
    $tag = get_the_tags($post->ID);
    $temp = stripslashes($views_options[‘most_viewed_template’]);
    $temp = str_replace(“%VIEW_COUNT%”, number_format_i18n($post_views), $temp);
    $temp = str_replace(“%POST_TITLE%”, $post_title, $temp);
    $temp = str_replace(“%POST_EXCERPT%”, $post_excerpt, $temp);
    $temp = str_replace(“%POST_CONTENT%”, $post->post_content, $temp);
    $temp = str_replace(“%POST_URL%”, get_permalink($post), $temp);
    $temp = str_replace(“%THUMBNAIL%”, $thumbnail, $temp);
    $temp = str_replace(“%TAG%”, $tag, $temp);
    $output .= $temp;

    太字部分を追加してみましたが、Arrayと表示されてしまいます。
    どこがいけないのでしょう。。。

    フォーラム: プラグイン
    返信が含まれるトピック: Popular Postsでのカテゴリ表示
    トピック投稿者 bumsos

    (@bumsos)

    wordpress-popular-posts.php の
    この部分(1184〜1192行)

    // category
    if ( $instance['stats_tag']['category'] ) {
    $post_cat = get_the_category( $p->id );
    $post_cat = ( isset($post_cat[0]) ) ? '<a href="'.get_category_link($post_cat[0]->term_id ).'">'.$post_cat[0]->cat_name.'</a>' : '';
    if ( $post_cat != '' ) {
    $stats .= ($stats == "") ? "<span class=\"wpp-category\">" . __('under', 'wordpress-popular-posts'). " {$post_cat}</span>" : " | <span class=\"wpp-category\">" . __('under', 'wordpress-popular-posts') . " {$post_cat}</span>";
    }
    }

    を編集すれば良いのだと思うのですが、

    どう変えれば良いのでしょうか。
    よろしくお願いします。

    トピック投稿者 bumsos

    (@bumsos)

    上記の通り修正したところ、望んでいた表示を実現する事が出来ました。
    何度もありがとうございました。

    トピック投稿者 bumsos

    (@bumsos)

    jdbbさん

    理解不足ですいません。
    $cat = $cat[0];
    を削除しましたが
    h2タグ内が表示されないままの状態です。

    現在このようになっています。

    $cat = get_category(get_query_var('cat'));
    $id = $cat->category_parent ? $cat->category_parent : $cat->cat_ID;
    $children = wp_list_categories('echo=0&title_li=&child_of=' . $id);
    if( ! preg_match('/(カテゴリーなし|No categories)/', $children) ) {
    echo "<h2>";
    $cat = get_the_category($id); { echo $cat->cat_name; };
    echo "</h2>";
    echo "<ul>";
    echo $children;
    echo "</ul>";

    よろしくお願いします。

    トピック投稿者 bumsos

    (@bumsos)

    jdbbさん
    回答ありがとうございます。

    フルーツの部分が
    echo “<h2>”;
    $cat = get_the_category(); $cat = $cat[0]; { echo $cat->cat_name; };
    echo “</h2>”;
    この部分だとした場合ですが

    言葉足らずで申し訳ありません。想像いただいた通りです。

    ご指摘のあった、6行目
    $cat = get_the_category();を
    $cat = get_the_category(id);に
    しました。

    しかし、状況を改善できず、h2タグ内が表示されなくなってしまいます。
    どうしたものでしょうか。

    フォーラム: 使い方全般
    返信が含まれるトピック: singleページでのカテゴリ表示
    トピック投稿者 bumsos

    (@bumsos)

    上記を当てはめて調整したところ、イメージとぴったりのものができました。
    大変助かりました。ありがとうございます。

6件の返信を表示中 - 1 - 6件目 (全6件中)