Support

Account

Home Forums Front-end Issues get_terms If Have Any Content in WYSIWYG Field Reply To: get_terms If Have Any Content in WYSIWYG Field

  • Actually, I think I solved this finally using part of a snippet I found pages deep on my Google search. I also didn’t realize I needed to specify which category to get the field data from even though I’m inside a foreach statement. get_field(‘category_bare_care’, $hiterm) is working fine. Hope this helps someone else!

    
    <ul>
        <?php $hiterms = get_terms("foxyshop_categories", array("orderby" => "menu_order", "parent" => 0)); ?>
        <?php foreach($hiterms as $key => $hiterm) : ?>
            <li>
                <?php echo $hiterm->name; ?>
                <?php if (get_field('category_bare_care', $hiterm)) :
    	            the_field('category_bare_care', $hiterm);
                endif; ?>
                <?php $loterms = get_terms("foxyshop_categories", array("orderby" => "menu_order", "parent" => $hiterm->term_id)); ?>
                <?php if($loterms) : ?>
                    <ul>
                        <?php foreach($loterms as $key => $loterm) : ?>
                            <li>
    	                        <?php echo $loterm->name; ?>
    	                        <?php if (get_field('category_bare_care', $loterm)) :
    					            the_field('category_bare_care', $loterm);
    				            endif; ?>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
        <?php endforeach; ?>
    </ul>