0

I get a white page in the frontend (not in the backend) after inserting the php code for the custom post type. See code: page-custom.php:

<div class="infoboxen">
 <div class="box">
<?php $loop = new WP_Query( array( 'post_type' => 'drei_boxen', 'posts_per_page' => 10 ) ); ?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>                     
 </div>
</div>

functions.php

add_action( 'init', 'create_my_post_types' );

function create_my_post_types() {
register_post_type( 'infobox', 
    array(
        'labels' => array(
            'name' => __( 'Infoboxen' ),
            'singular_name' => __( 'Infoboxen' ),
            'description' => __('Zur Erstellung der vier Boxen auf der Startseite unterhalb des Sliders')
        ),
        'public' => true,
    )
);

}

Any ideas why? If I delete the code from the page-custom.php it works. But with the code, I only get a white page and white source code.

  • Is the code above all that you've placed inside your template? If so, this is a PHP syntax error that's causing the white screen. If not, please post more code. Thanks – Brian Fegter Sep 14 '12 at 3:56
  • Please read about debugging in WP Codex. Whitescreen = no debug turned on. – kaiser Sep 23 '12 at 15:08
0

You forgot about endwhile; at the end of loop.

Using template don't forget to get_header() and get_footer()

Sample:

<?php
/*
  Template Name: Test
 */
?>

<?php get_header(); ?>

<div class="infoboxen">
    <div class="box">
        <?php $loop = new WP_Query(array('post_type' => 'drei_boxen', 'posts_per_page' => 10)); ?>

        <?php while ($loop->have_posts()) : $loop->the_post();
        endwhile; ?>                     
    </div>
</div>

<?php get_footer(); ?>
|improve this answer|||||
  • oh..right. THANKS a lot. (there was no header and footer, because i just copied a part of the whole document) but thanks! saved my day! – Max Aug 24 '12 at 11:28

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