Probably a simple, stupid question, but:
I'm trying to create a page that displays a list of all pages that include a specific ACF value.
I copied page.php from my active theme folder, renamed it page-[list page slug].php, and added the ACF query thusly:
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package SKT Spiritedlite
*/
get_header(); ?>
<div class="container">
<div class="page_content">
<section class="site-main">
<?php if( have_posts() ) :
while( have_posts() ) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
<?php
$posts = get_posts(array(
'post_type' => 'page',
'meta_key' => 'genre',
'meta_value' => 'rock'
));
if( $posts ): ?>
<ul>
<?php foreach( $posts as $post ):
setup_postdata( $post );
?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
</div><!-- entry-content -->
<?php endwhile; else : endif; ?>
</section><!-- section-->
<div class="clear"></div>
</div><!-- .page_content -->
</div><!-- .container -->
<?php get_footer(); ?>
Uploading this file to my templates folder instantly 500's my site.
I'm sure I'm missing something obvious, but I'm new to tweaking php at this level.
Thanks!