css スクロールバーのデザイン

.f-news {

  &__list {
    height: 500px;
    overflow-y: scroll;

    &::-webkit-scrollbar-thumb {
      background: #82c582;
      border-radius: 8px;
      border-right: 4px solid transparent; /* 透明なボーダーをつける */
      border-left: 4px solid transparent; /* 透明なボーダーをつける */
      background-clip: padding-box; /* 背景を切り取る */
    }
    &::-webkit-scrollbar-track {
      /* 上下に余白を付ける */
      margin-top: 30px;
      margin-bottom: 30px;
    }
    &::-webkit-scrollbar {
      width: 16px;
    }
}

WP ACF PDFを表示させる

PDF Image GeneratorプラグインをインストールしてUP

下記から最新をダウンロード

PDF Image Generator – WordPress plugin | WordPress.org

ACFのファイルの戻り値は配列で設定をします

テンプレートファイルに記述

<?php
$args = array(
  'post_type' => 'lunch_post',
  'posts_per_page' => 1,
  'order' => 'DESC',
  'tax_query' => array(
    array(
      'taxonomy' => 'lunch_cat',
      'terms' => array('kashinomi_month'),
      'field' => 'slug'
    ),
  ),
);
$the_query = new WP_Query($args);
?>
<div class="inner _menuMonth">
  <h3 class="p-title03">今月の献立</h3>

  <?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>

      <?php
      if ($field = get_field("lunch_pdf")) {

        $attr = array(
          'id' => $field['id'],
          'alt' => $field['alt']
        );

        echo "<a href='{$field["url"]}' target='_blank' class='menu__month'>" .
          wp_get_attachment_image($field["id"], "thumbnail", 0, $attr) . "</a>";
      }
      ?>


  <?php endwhile;
  endif;
  wp_reset_postdata(); ?>
</div>

下記がPDFを表示させる

<?php
if ($field = get_field("lunch_pdf")) {

  $attr = array(
    'id' => $field['id'],
    'alt' => $field['alt']
  );

  echo "<a href='{$field["url"]}' target='_blank' class='menu__month'>" .
    wp_get_attachment_image($field["id"], "thumbnail", 0, $attr) . "</a>";
}
?>

WP カスタム投稿で1件目だけ表示を変えたいとき

<?php
$args = array(
  'post_type' => 'lunch_post',
  'posts_per_page' => -1,
  'order' => 'DESC',
  'tax_query' => array(
    array(
      'taxonomy' => 'lunch_cat',
      'terms' => array('kashinomi'),
      'field' => 'slug'
    ),
  ),
);
$the_query = new WP_Query($args);
?>
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
    <?php global $the_query;

    if ($the_query->current_post === 0) { ?>

      1件目の表示

    <?php } else { ?>

      2件目以降

    <?php } ?>


<?php endwhile;
endif;
wp_reset_postdata(); ?>

ACF サブフィールドのショートコードを表示させる

一度、get_sub_field()でショートコードを取得し、echo do_shortcode($s);で表示させる

<?php if (have_rows('facility')) : ?>
<?php while (have_rows('facility')) : the_row(); ?>

<?php $table = get_sub_field('table');
echo do_shortcode($s); ?>

<?php endwhile; ?>
<?php endif; ?>