Support

Account

Home Forums ACF PRO Returning items (Settings page) category

Helping

Returning items (Settings page) category

  • Hello,
    I’m currently working on the following within a client’s website.

    In the “Page settings” I have configured the ability to insert photos that can be tagged. I did not deliberately choose the “Gallery” model, as it is not possible to add labels to these photos. That’s why I chose a custom gallery with labels. At the same time, these labels can be managed by the client himself, so he can create a new category at any time, without my intervention.

    The categories have this hierarchy:
    – 1) Main categories (e.g. CABELS)
    – 2) Subcategories (e.g. SMALL, LARGE)

    I was able to use foreach to get a listing of the subcategories as well, but I don’t know how I can now get all the items that have that category.

    Could I ask for a foreach that takes as input the id or name of the subcategory(“label”) and returns me all the items that are labelled this way?

    I am sending the actual code that I found publicly somewhere on the forum and I need to modify it to get the URL of the IMAGE, DESCRIPTION (ACF field) + URL (ACF field). The code can be completely different, I just need to go through all the existing subcategories (level 2).

    
       <div class="container-fluid">
            <div class="row">
                <div class="tab-content" id="pills-tabContent">
                    <?php /** Loop through every term */
                    foreach ($terms as $term) {
                        /** Skip term if it has children */
                        if ($term->parent) {
                            continue;
                        }
                        if ($hierarchy[$term->term_id]) {
                            foreach ($hierarchy[$term->term_id] as $child) {
                                /** Get the term object by its ID */
                                $child = get_term(
                                    $child,
                                    "kategorie--inspirace"
                                ); ?>
                    <div class="tab-pane fade show" id="pod<?php echo $child->slug; ?>" role="tabpanel"
                        aria-labelledby="pod<?php echo $child->slug; ?>-tab">
    
                       <strong> In this section I need to get the url to the image in the settings page, description and link.</strong>
    
                    </div>
                    <?php
                            }
                        }
                    } ?>
                </div>
            </div>
        </div>
    

    I am sending a screenshot in the attachment:
    – settings page
    – acf field configuration in settings page

    Thank you
    Robert Glogowski

  • I’m sorry, I didn’t post the pictures.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.