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:



 * 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(); ?>


$posts = get_posts(array(
    'post_type'     => 'page',
    'meta_key'      => 'genre',
    'meta_value'    => 'rock'

if( $posts ): ?>


    <?php foreach( $posts as $post ): 

        setup_postdata( $post );

            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>

    <?php endforeach; ?>


    <?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.


  • Obviously from the way my code posted, something isn't right. Here's the missing chunk. $posts = get_posts(array( 'post_type' => 'page' 'meta_key' => 'genre', 'meta_value' => 'rock' )); Mar 8, 2017 at 0:54

1 Answer 1


On some servers, errors in PHP code cause 500 errors. I can't test your code right now, but since you said the error only happens when you use your new page template this is most likely.

Yes, it's really annoying to just have a blank page and not even have a clue of what went wrong. To find the error, you can either:

  1. Make sure your PHP is configured to show errors properly

  2. Look at your PHP error log

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.