カスタムフィールドに入れた数値をarrayに代入

まずはカスタムフィールドで[テキスト]で数値を自由入力
ex.7
フィールド名を「numberID」

<?php
    $●● = get_field('フィールド名 ex. numberID');//カスタムフィールドの値を変数に格納
?>

<?php 
$args = ['tag_id' => $●●];
?>
<div class="xxx">
<ul>
<?php 
// 条件を渡して記事を取得
$custom_posts = get_posts($args);
foreach ( $custom_posts as $post ): setup_postdata($post); ?>
<li><?php the_post_thumbnail(); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<!--- タグによる自動取得 --->

勉強させてもらったサイト

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です