フォーラムへの返信

15件の返信を表示中 - 1 - 15件目 (全15件中)
  • トピック投稿者 ryouma

    (@ryouma)

    gblsm様
    おっしゃる通りです。自力で作れるようPHPの参考書籍やWordPressプラグイン開発の書籍なども見てはいるのですが、
    ついついコピペに頼ってばかりで・・・

    なお、最初に記載して頂いた内容も既に挑戦したものでしたが、なぜそうなったのかまではわかりませんでした。
    もっと勉強しないといけませんね。

    お二方とも本当にありがとうございました。

    トピック投稿者 ryouma

    (@ryouma)

    ikaring様 
    返信ありがとうございます!

    記述して頂いたものでやってみましたが、うまく表示できませんでした。恐らく、私が前後に記述しているソースに何か誤りがあるのかもしれません。@gblsm様の記載して頂いたものでうまく表示することができました。
    ありがとうございました!

    トピック投稿者 ryouma

    (@ryouma)

    返信ありがとうございます。

    <?php
      $cats = get_the_category();  // 現在の投稿のカテゴリー(配列)
      do {
        $cat = array_shift( $cats );  // 配列の先頭を切り出す
        if ( NULL == $cat )  // 配列が空だった(カテゴリーがない)
          break;
      } while ( 0 != $cat->parent );  // 親カテゴリーがあるなら繰り返す
    
      if ( NULL == $cat ) {
        // 投稿に親カテゴリーがひとつも付いていない
      } else {
        $cat_link = get_category_link( $cat->term_id );  // 親カテゴリーのアーカイブ
        echo '<span class="cat_icon ', $cat->slug, '" />';
        echo '<a href="', esc_url( $cat_link ), '">';
        echo $cat->name, '</a></span>';
      }
    ?>

    記載して頂いた上記の記述で
    index.php(トップ)とsingle.phpともに試させて頂いたところ、完璧に思い通りの表示になりました!

    ようやく解決する事ができて本当に嬉しく思います。助かりました。
    ありがとうございました!

    フォーラム: プラグイン
    返信が含まれるトピック: PostViews テンプレートへの記述方法について
    トピック投稿者 ryouma

    (@ryouma)

    自己解決しましたので、投稿させて頂きます。
    私がやりたかった事は、PostViewsを使って、人気記事にサムネイルを表示させるのと、順位毎にクラスを付加させることです。

    プラグインフォルダのwp-postview.phpを開き以下の記述がある箇所を探します。
    (Postviewsのバージョンは1.66です。)

    foreach ($most_viewed as $post) {
                        $post_views = intval($post->views);
                        $post_title = get_the_title($post);
                        if($chars > 0) {
                             $post_title = snippet_text($post_title, $chars);
                        }
                        $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
                        $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("%POST_DATE%", get_the_time(get_option('date_format'), $post), $temp);
                        $temp = str_replace("%POST_TIME%", get_the_time(get_option('time_format'), $post), $temp);
                        $output .= $temp;
                   }

    上記と同じような記述が計6カ所あるのでそれら全てに、サムネイルを表示させる為の変数%THUMBNAIL%と順位毎にクラスを付与させる為の変数%RANKING_NO%を追加します。

    $rankingNo = 1;//順位を計数する変数の定義
                   foreach ($most_viewed as $post) {
                        $post_views = intval($post->views);
                        $post_title = get_the_title($post);
                        if($chars > 0) {
                             $post_title = snippet_text($post_title, $chars);
                        }
                        $post_excerpt = views_post_excerpt($post->post_excerpt, $post->post_content, $post->post_password, $chars);
                        $thumbnail = get_the_post_thumbnail($post->ID,"thumbnail",true);//サムネイルを表示
                        $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("%RANKING_NO%", $rankingNo, $temp);//変数への代入
                        $temp = str_replace("%POST_DATE%", get_the_time(get_option('date_format'), $post), $temp);
                        $temp = str_replace("%POST_TIME%", get_the_time(get_option('time_format'), $post), $temp);
                        $output .= $temp;
                        $rankingNo++;//順位のカウントアップ
                   }

    ※上記の記述を他5カ所にも同じように記述します。

    PostViewsの設定画面を開き、「Most Viewed Template:」右のテキスト入力欄に%THUMBNAIL%と%RANKING_NO%を追加記述します。

    ちなみに僕は下記のように記述しています。

    <div class="post">
    <span class="no%RANKING_NO%"></span>
    <p class="post_image">%THUMBNAIL%</p>
    <h3><a href="%POST_URL%"  title="%POST_TITLE%">%POST_TITLE%</a></h3>
     <p> %VIEW_COUNT% views</p>
    </div>

    順位毎にクラスを付与させる為の変数をclass=“no%RANKING_NO%”このようにクラス名の場所に記述。
    続いてサムネイルを表示させる為の変数「%THUMBNAIL%」はそのまま記述しても大丈夫そうです。

    参考URL:WordPress(ワードプレス)でWP-PostViewsの順位表示を画像にしてみたい
    WordPress人気記事にサムネイル表示させる方法とカスタマイズ

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

    (@ryouma)

    私もたった今、全く同じ内容で悩んでおりました。
    PHPでのやり方は分かりませんでしたが、とりあえずcssで消しました。

    _html

    <ul>
    <span>カテゴリ:<a href"#">リンゴ</a></span>
    </ul>

    _css

    span{ visibility:hidden;}
    span a{ visibility:visible;}

    もしPHPで解決なさっていらしたら、教えて頂けると嬉しいです。

    トピック投稿者 ryouma

    (@ryouma)

    はっ!そこでしたか。。。
    PHPも超素人なもので、失礼致しました。回答してくださり、本当にありがとうございました。

    トピック投稿者 ryouma

    (@ryouma)

    試行錯誤の上、、、、
    下記の記述でspanで囲った記事数の表示部分をaタグの中にいれることができました。

    add_filter( 'wp_list_categories', 'my_list_categories', 10, 2 );
    function my_list_categories( $output, $args ) {
      $output = preg_replace('/<\/a>\s*\((\d+)\)/',' <span>($1)</span></a>',$output);
      return $output;
    }

    しかし、
    括弧を消す場合はこれまたどのような記述になるのでしょうか。。。
    カテゴリ(1)これを➡カテゴリ2 のように()を消したいのですが、全く検討つきません。
    どなたかご教授お願い致します。

    フォーラム: 使い方全般
    返信が含まれるトピック: 管理画面のカスタマイズについて
    トピック投稿者 ryouma

    (@ryouma)

    回答ありがとうございます。
    返信が遅くなり申し訳ありません。

    Advanced Custom Fieldsの方も色々と調べてみましたが、テーマでの作成のため、自力で無料テーマを解読することにしました。

    なんとかこちらの無料テーマのhttps://wordpress.org/themes/sixteen仕組みを解読し、アレンジしたものを実装できそうです。

    ありがとうございました!

    フォーラム: プラグイン
    返信が含まれるトピック: カテゴリ名の色分け
    トピック投稿者 ryouma

    (@ryouma)

            

    フォーラム: プラグイン
    返信が含まれるトピック: カテゴリ名の色分け
    トピック投稿者 ryouma

    (@ryouma)

    gatespace様、ありがとうございます。gatespace様のプラグインで無事に設置する事ができました。とても助かりました。

    いくら探しても見つからなかったので、本当に助かりました!
    ありがとうございました。

    フォーラム: プラグイン
    返信が含まれるトピック: カテゴリ名の色分け
    トピック投稿者 ryouma

    (@ryouma)

    こんばんは。
    gatespace様、リンク先拝見させて頂きました。まさに理想通りのプラグインです!
    ただ、知識不足でどのようにテンプレートファイルに記述すれば良いか分かりませんでした。

    恐縮ですが、例えば以下のコード(Twenty Twelve)にはどのように記述すれば良いでしょうか。自分なりにやってみましたがさっぱり分かりませんでした。。

    <?php get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    		<?php if ( have_posts() ) : ?>
    
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php twentytwelve_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    
    			<article id="post-0" class="post no-results not-found">
    
    			<?php if ( current_user_can( 'edit_posts' ) ) :
    				// Show a different message to a logged-in user who can add posts.
    			?>
    				<header class="entry-header">
    					<h1 class="entry-title"><?php _e( 'No posts to display', 'twentytwelve' ); ?></h1>
    				</header>
    
    				<div class="entry-content">
    					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'twentytwelve' ), admin_url( 'post-new.php' ) ); ?></p>
    				</div><!-- .entry-content -->
    
    			<?php else :
    				// Show the default message to everyone else.
    			?>
    				<header class="entry-header">
    					<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
    				</header>
    
    				<div class="entry-content">
    					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
    					<?php get_search_form(); ?>
    				</div><!-- .entry-content -->
    			<?php endif; // end current_user_can() check ?>
    
    			</article><!-- #post-0 -->
    
    		<?php endif; // end have_posts() check ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    お忙しい中、申し訳ありませんが、お教え頂けると大変助かります。宜しくお願い致します。

    フォーラム: プラグイン
    返信が含まれるトピック: カテゴリ名の色分け
    トピック投稿者 ryouma

    (@ryouma)

    Takano様、失礼致しました。
    タイトルはこのままで大丈夫です☆

    こちらのページでLIG紹介されているプラグイン。カテゴリにアイコンを設定できるそうです。こちらの使用を検討しておりますが、使えるか心配です。
    gatespaceさま、ありがとう御座います。是非試させて頂きます。

    トピック投稿者 ryouma

    (@ryouma)

    hissyさん、回答ありがとうございます。
    さくらインターネットコントロールパネルで「PHPの編集」に下記を記述する事で解決致しました。

    upload_max_filesize = 80M
    post_max_size = 120M

    サーバー側の設定だとは思いもよりませんでした。本当にありがとうございました。

    トピック投稿者 ryouma

    (@ryouma)

    ixkaitoさん、回答ありがとうございます。
    質問内容が分かりづらく、大変申し訳ありません。
    カスタムフィールドの名前は「amazon」で、値はリンク付き画像のURLを記述する予定です。
    私、PHPは素人並みの知識しか無く、下記の記述をカスタマイズしようと試みましたが、分かりませんでした。
    ちなみに下記コードを記述するとclass=””を表示されてしまいます。
    恐縮ですが、お教え頂けると嬉しいです。

    <?php
    $custom_fields = get_post_custom();
    $my_custom_field = $custom_fields['class'];
    echo 'class="';
    foreach ( $my_custom_field as $key => $value ){
    	echo $value . ' ';
    }
    echo '"';
    ?>
    トピック投稿者 ryouma

    (@ryouma)

    失礼致しました!
    タイトルは「WordPressのカスタムフィールドにclass名を付与する方法について」です。
    申し訳ありません。

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