-1

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:

<?php
    //Template Name: Home
    get_header();
?>
<div class="container">
    <header>
        <h1><?php echo get_option('tiny_head_title'); ?></h1>
        <p><?php echo get_option('tiny_head_description'); ?></p>
    </header>
    <?php
        $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">
        <?php
            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; ?>
                <h2>
                    <a href="<?php the_permalink(); ?>">
                        <?php the_title(); ?>
                    </a>
                </h2>
                <?php the_excerpt(); ?>
            </article>
        <?php endwhile; ?>
    </div>
    <div class="pagination">
        <?php
            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'
            ));}
        ?>
    </div>
    <?php endif; ?>
</div>
<?php get_footer(); ?>

closed as off-topic by fuxia Dec 17 '14 at 17:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
-2

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

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