Custom page template for Stargazer child theme fails

4 Replies ·

  1. I’m using a child theme for Stargazer. I wanted to create a page template based on the Stargazer page.php.

    So, I copied content/page.php to my theme folder as /mytemplate.php. Other than adding the Template Name: code comment I didn’t change it for now. Assigning it to a page and loading it fails with

    Warning: count(): Parameter must be an array or an object that implements Countable in /wp-includes/post-template.php on line 284

    It is caused when <?php the_content(); ?> is evaluated, doh.

    There is a long discussion about several aspects / causes for this error at but I don’t see how any of that applies to my case.

    I feel I’m missing something obvious.

  2. marcelstoer

    Got it, thank you. The reason I ended up copying page.php is because I simply needed a page without title. How can this be accomplished with minimal modification effort? If I copy index.php I would have to copy everything else as well, no (if I only need to tweak the page template)?

  3. Justin Tadlock

    You’d need to copy index.php. Then, replace this line within the file:

    <?php hybrid_get_content_template(); // Loads the content/*.php template. ?>

    With this code from /content/page.php, which leaves out the header/title code:

    <article <?php hybrid_attr( 'post' ); ?>>
        <div <?php hybrid_attr( 'entry-content' ); ?>>
            <?php the_content(); ?>
            <?php wp_link_pages(); ?>
        </div><!-- .entry-content -->
        <footer class="entry-footer">
            <?php edit_post_link(); ?>
        </footer><!-- .entry-footer -->
    </article><!-- .entry -->