Help us understand the problem. What is going on with this article?

新着記事一覧の中に特定の固定ページを差し込む【WordPress】

<?php 

// 条件
$args = Array(
        'post_type' => 'post',
        'posts_per_page' => '20', // 投稿数
        'category' => '2,3,4,10', // カテゴリを絞る場合
);
$the_query = get_posts( $args );

echo '<dl>'."\n";

// ループ開始
if ($the_query) {

    global $post;
    foreach ($the_query as $post) {

        setup_postdata($post);

        $loop++;

        // 上から2番目までNEWマークを付ける
        $new_class = '';
        if ($loop < 2) {
            $new_class = ' class="new_topics"';
        }

        // 挿入する固定ページ(1)
        if (!$loop_flag1) {
            if(strtotime(get_the_date('Y-m-d')) < strtotime('2019-10-25')) {
                // 一度しか表示させないためのフラグ
                $loop_flag1 = 1;
                echo '<dt>2019/10/25</dt><dd '.$new_class.'><a href="http://www.xxxx.com/page1">固定ページのタイトル</a></dd>'."\n";
            }
        }

        // 挿入する固定ページ(2)
        if (!$loop_flag2) {
            if(strtotime(get_the_date('Y-m-d')) < strtotime('2018-09-06')) {
                // 一度しか表示させないためのフラグ
                $loop_flag2 = 1;
                echo '<dt>2018/9/6</dt><dd><a href="http://www.xxxx.com/page2">固定ページのタイトル</a></dd>'."\n";
            }
        }

        // 投稿の更新情報
        echo '<dt>'.get_the_time('Y/m/j').'</dt><dd '.$new_class.'><a href="'.get_the_permalink().'">'.get_the_title().'</a></dd>'."\n";
    }
}

echo '</dl>'."\n";

wp_reset_postdata();

?>
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away