• Philljc

    (@philljc)


    Either of these two conditions work by themselves, but when I put them in this if/else statement, I always receive an error:

    Parse error: syntax error, unexpected ‘}’ in /public_html/timeline/wp-content/themes/timeline/index.php on line 65

    The conditional is:

    <?php if (is_front_page()) { ?>
        <?php
            $current_year = date('Y');
            $args = array('category_name' => $current_year);
            $category_posts = new WP_Query($args);
    
            if($category_posts->have_posts()) :
                while($category_posts->have_posts()) :
                    $category_posts->the_post();
        ?>
    <?php } else { ?>
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php } ?>

    Is it because I’m putting PHP tags in PHP? I can’t make sense of it.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    the nesting of the conditional statements does not work the way you are trying;

    you will need to use a full loop for the $category_posts

    Thread Starter Philljc

    (@philljc)

    Can you elaborate on why that wont work?

    As I said, if I use either piece of code on its own, it’s fine, why would it break in a conditional statement?

    [Bump deleted]

    Vaib

    (@vaibhavg)

    hi,
    Please Paste your full code then I will try to find the problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_front_page problem’ is closed to new replies.