Skip to content

Instantly share code, notes, and snippets.

@wadadanet
Last active November 15, 2019 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadadanet/b7e74ff2cdee3fa56caff013daba1784 to your computer and use it in GitHub Desktop.
Save wadadanet/b7e74ff2cdee3fa56caff013daba1784 to your computer and use it in GitHub Desktop.
新着情報一覧表示
<ul>
<?php if ( have_posts() ): ?>
<?php while ( have_posts() ) : the_post();?>
<?php get_template_part( 'template-parts/item', 'news' ); ?>
<?php endwhile; ?>
<?php endif;?>
</ul>
<?php $news_query = new WP_Query('post_type=news'); ?>
<ul>
<?php if ( $news_query->have_posts() ): ?>
<?php while ( $news_query->have_posts() ) : $news_query->the_post();?>
<?php get_template_part( 'template-parts/item', 'news' ); ?>
<?php endwhile; ?>
<?php endif;?>
<a href="<?= get_post_type_archive_link('news') ?>">新着情報一覧</a>
</ul>
<?php
// template-parts/items-news.phpファイルです。
$link_active = get_field("link-active");
if($link_active) {
$url = get_field("url");
} else {
$url = get_permalink();
}
?>
<li>
<a href="<?= $url ?>"><?= the_title(); ?></a>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment