Thanks in advance for your help.

I am getting this error in my WordPress theme:

Notice: Use of undefined constant - assumed ' ' in .../themes/theme/homepage.php on line 10

Here is the contents of file it mentions:

    //Template Name: Home
<div class="container">
        <h1><?php echo get_option('tiny_head_title'); ?></h1>
        <p><?php echo get_option('tiny_head_description'); ?></p>
        $paged = get_query_var('page');
        $home = new WP_Query(array(
            'post_type' => 'post',
            'posts_per_page' => 6,
            'paged' => $paged
        if ($home->have_posts()):
    <div class="posts">
            while ($home->have_posts()): $home->the_post();
            if (is_sticky()):
            <article id='<?php the_ID();?>' <?php post_class('sticky');?>>
            <?php else: ?>
            <article  id='<?php the_ID(); ?>' <?php post_class();?>>
            <?php endif; ?>
                    <a href="<?php the_permalink(); ?>">
                        <?php the_title(); ?>
                <?php the_excerpt(); ?>
        <?php endwhile; ?>
    <div class="pagination">
            global $home;
            $total = $home->max_num_pages;
            if ($total > 1) {
            if (!$current_page = get_query_var('page'))
                $current_page = 1;
                $format = get_option('permalink_structure') ? 'page/%#%/' : '&page=%#%';
            echo paginate_links(array(
                'base' => get_pagenum_link(1) . '%_%',
                'format' => $format,
                'current' => $current_page,
                'total' => $total,
                'mid_size' => 4,
                'type' => 'plain'
    <?php endif; ?>
<?php get_footer(); ?>
  • a copy and paste of your code does not produce an error – Milo Dec 11 '14 at 23:28
  • @Milo, I take it that means that it is a conflict with something else in my site? My security plugin perhaps... it changes my /wp-content directory to "/new-name" – the Freelancer Dec 11 '14 at 23:30
  • Can you run your code through a formatter and run it again with the new line number? Format it so that the <?php ?> tag spam is removed and your arrays and code are indented? I suspect the issue is inside the array passed into your WP_Query object, but it's not possible to tell when you have so much code on a single line – Tom J Nowell Dec 12 '14 at 0:11
  • @TomJNowell, is there a formatter online that you recommend? I've never done that before. However, I have added blank lines before and after the line in question to ensure that it is the line causing the error. – the Freelancer Dec 12 '14 at 0:27
  • 1
    @TomJNowell No Sir! Error is gone! Thanks so much! :) – the Freelancer Dec 12 '14 at 2:56

Thanks to @TomJNowell for suggesting running the snippet through a code cleaner, which fixed this issue!

| improve this answer | |

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