WordPressを使って人気順にフォントサイズを大きく表示するソースコードを作っていきます。人気順にフォントサイズを大きく表示することをタグクラウドともいいます。
現役エンジニア以外の文系未経験の方でも簡単に作れるようにソースコードを掲載しました。
本記事で必要になる画面(ソースコード)は下記に記しております。
<div class="widget"> <h2>タグクラウド</h2> <?php $args = array( 'smallest' => 14, //人気の少ないタグを表示する場合のフォントサイズ 'largest' => 18, //人気の多いタグを表示する場合のフォントサイズ 'unit' => px, //px, pt, e,. %のフォントサイズが指定できる 'nunber' => 0, //タグの最大表示数を指定する(上限45個) 'format' => flat, //flat, list, arrayで指定 'taxonomy' => post_tag, // 'echo' => true, // ); ?> <p class="tagcloud"> <?php wp_tag_cloud($args); ?> </p> </div>
おのおのミスしないようにプログラミングして作成していきましょう。
【WordPress・PHP】人気順にフォントサイズを大きく表示するためのソースコード
<?php while($my_query->have_posts()) : $my_query->the_post(); get_template_part('sidebarposts'); endwhile; ?>
<li class="clearfix"> <div class="sidebar-posts-title"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p class="sidebar-date"> <?php the_time(get_option('date_format'));) ?> </p> <p class="sidebar-comment-num"> <?php comments_popup_link('comment : 0','comment : 1','comments : %'); ?> </p> </div> <p class="sidebar-thumbnail-box"> <a href="<?php the_permalink(); ?> title="「<?php the_title(); ?>」の続きはこちら""> <?php //アイキャッチ画像 if(has_post_thumbnail()): the_post_thumbnail(array(75, 75)); else : ?> <img src="<?php echo get_template_directory_uri(); ?> /images/noimage.gif" width="75" height="75" alt="" /> <?php endif; ?> </a></p></li>