-2

I have this bit of php code in my wordpress theme where tags of posts are to be fetched and displayed in different colors as specified. But all i get is a Parse error. I would be thankful if someone could help.

this is the code

<div class="category-light">
                    <?php $recent = new WP_Query(array( 'cat' => $categories, 'posts_per_page' => $number )); while($recent->have_posts()) : $recent->the_post();?>
                    <div class="cat-light-top">

                        <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>
                            <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('post-thumb'); ?></a>
                        <?php } ?>

                        <style type="text/css">

                        .poli {
                                color: #6868eb;
                                float: left;
                                font:  13px/10px oswald,helvetica, sans-serif;
                                margin-bottom: 5px;
                                padding-bottom: 5px;
                                text-transform: uppercase;
                                }
                        </style>

               <?php 
                        if ($all_the_tags);
                        $all_the_tags = get_the_tags();
                        foreach($all_the_tags as $this_tag) {
                            if ($this_tag->name == "politics" ) {
                        ?>

                       <span class="poli" style="color:#5e6de0;">politics</span>

                        <?php   } else if ($this_tag->name == "front" ) { ?>

                        <span class="poli" style="color:#a33030;">front</span>

                        <?php   } else {    
                                // it's neither, do nothing
                        ?>
                                <!-- not tagged as one or the other -->
                        <?
                            }
                        }
                        }
                ?>
                    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?> </a></h2>  

                    </div><!--cat-light-top-->
                        <?php endwhile; ?>
                </div><!--category-light-->

Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) in C:\wamp\www\daily\wp-content\themes\Daily Guide\widgets\widget-catlight.php on line 96, and line 96 is the part of the code that has ''

K.Lumor
  • 1
  • 1
  • could you include the error pls and if posibble state in which line it happens?? – DocRattie Jul 17 '15 at 11:00
  • 1
    What does the parse error say. Reread the error, it tells you **exactly** where the issue is and what syntax it expects in stead – Pieter Goosen Jul 17 '15 at 11:00
  • Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE) in C:\wamp\www\daily\wp-content\themes\Daily Guide\widgets\widget-catlight.php on line 96, and line 96 is the part of the code that has '' – K.Lumor Jul 17 '15 at 11:35

1 Answers1

0

Typo:

Replace if ($all_the_tags):

With: if ($all_the_tags) {

Number of opening and closing curly braces were not matching.

That was the parse error.

Pupil
  • 23,834
  • 6
  • 44
  • 66