Q.商品記事ページの下部に表示される商品記事の一覧を非表示にしたい
商品の記事を開くと商品説明の下に、その記事のカテゴリーに属する他の記事が一覧で表示されますが、この商品記事一覧を非表示にする方法を教えてください。
A.下記のphpファイルの該当箇所をコメントアウトします
編集するファイル:single-menu.php
コメントアウトする箇所:
<!--
<div>
<h3 class="headline2"><span><?php echo $cat_name; ?></span><?php if (!empty($cat_data['sub_title'])){ ?><?php echo $cat_data['sub_title']; ?><?php }; ?></h3>
<?php
//カテゴリーに属する記事を取得
$args = array( 'post_type' => 'menu', 'posts_per_page'=>-1 , 'orderby' => 'date', 'order' => 'DESC', 'menu_category' => $cat_slug);
$menu_list = get_posts($args);
if ($menu_list) {
?>
<ol class="clearfix">
<?php
foreach ($menu_list as $post) : setup_postdata ($post);
$large_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
$small_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'size1' );
if ( has_post_thumbnail()) {
?>
<li>
<a class="lightbox" href="<?php echo $large_image[0]; ?>" data-imagelightbox="a"><img src="<?php echo $small_image[0]; ?>" width="" height="" alt="<?php the_title(); ?>" /></a>
<a class="title" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<p class="excerpt"><?php if (has_excerpt()) { the_excerpt(); } else { new_excerpt(120); }; ?></p>
</li>
<?php }; endforeach; wp_reset_query(); ?>
</ol>
<?php }; ?>
</div>
-->
※上記箇所を「<!–」と「–>」で囲いコメントアウトしています。
この記事は役に立ちましたか?
もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!