Home Forums General Issues Taxonomy Term Image Field for child Categories


Taxonomy Term Image Field for child Categories

  • Hi,

    Hope somebody can help me because I tried everything.

    On a website I want to add a picture for te child categories “Diesel motoren” and “Vovkad”. I added Image to Category like this:
    and added pictures to my child categorie.

    My code of the website is this:

    <div class="container">
      <div class="row">
        <div class="col-md-12">
          <div class="products_page">
            <h1>Kies een categorie</h1>
            $categories = get_categories( array(
                'orderby' => 'name',
                'parent'  => 12
            ) );
            foreach ( $categories as $category ) {
              if ($category->slug != 'geen-onderdeel-van-een-categorie'){ ?>
                <?php $category_link = get_category_link( $category->term_id ); ?>
                <a href="<?= $category_link; ?>"><button><?php echo $category->name; ?></button></a>
                foreach($categories as $category):
                  $image = get_image('category_image', $category);
                  echo '<img src="'.$image['url'].'" alt="'.$image['alt'].'" />';
              <?php }
            }//end foreach ?>        

    If something isn’t clear, let me know.


  • get_image() is not an ACF function

    $image = get_field('category_image', $category);
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Taxonomy Term Image Field for child Categories’ is closed to new replies.