-2

I have this code.

<?php
$categories = get_categories( array(
    'taxonomy' => 'events_cat',
    'orderby' => 'name',
    'order'   => 'ASC'
));
foreach ($categories as $category) ?> 
    <div>
        <?php name(); ?>
    </div>
<?php endforeach; ?>

I try show list categories (foreach), but this no work. any idea why it does not work?

Juan David
  • 227
  • 2
  • 9
  • 2
    Missing `:` after `foreach ($categories as $category)`, it should be `foreach ($categories as $category): ?> ` – Rajdeep Paul Sep 17 '17 at 12:23
  • Possible duplicate of [PHP Parse/Syntax Errors; and How to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Rajdeep Paul Sep 17 '17 at 12:25

1 Answers1

1

My solution

Add: foreach ($categories as $category) : ?>
Update: <?php echo $category->cat_name; ?>

<?php
$categories = get_categories( array(
        'taxonomy' => 'events_cat',
    'orderby' => 'name',
    'order'   => 'ASC'
));
foreach ($categories as $category) : ?>
    <div>
        <?php echo $category->cat_name; ?>
    </div>
<?php endforeach; ?>
Juan David
  • 227
  • 2
  • 9