WordPressの年別アーカイブページで「次の年」「前の年」のリンクを表示する方法 WordPressのarchive.phpのような年別アーカイブページで、「次の年」「前の年」のようなリンクを表示する方法です。 まず、functions.phpに次のように関数を記述します。//次の年のリンクを取得 function get_next_year_link() { $this_year = intval( get_the_time( 'Y' ) ); $next_year = $this_year + 1; //次の年に投稿があるか調べる $args = array( 'year' => $next_year, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { return get_year_l
![WordPressの年別アーカイブページで「次の年」「前の年」のリンクを表示する方法 | 着ぐるみ技術部ペンギン](https://cdn-ak-scissors.b.st-hatena.com/image/square/0362d5c48deac1c70a141d316db4af7a1cdaf02b/height=288;version=1;width=512/http%3A%2F%2Fwww.kigurumi.asia%2Ftech%2Fwp-content%2Fplugins%2Fwp-ogp%2Fdefault.jpg)