Support

Account

Home Forums ACF PRO Create admin select list

Helping

Create admin select list

  • I have created a field group to show on a certain page template.

    What I want is to have a select dropdown available on all pages that are not of this template(I know how to exclude acf from said template already).

    The contents of the select will be a title for each of the created field groups from the page template. There is a Title field in this group which is where I would like to get that from.

    So if there are three pages that use this template and all have their unique info saved. The select will present you with these three options. Then in page.php or header.php I will check for the value of this select option and pass the page id so I can get the appropriate get_field to display.

    Example: If location A is selected for /page1/ in the backend the header will output the phone number for location A dynamically.

    <?php $loc_phone = get_field('location_phone', SELECTED_PAGE_ID); ?>
    <?php echo '<a href="tel:'. $loc_phone .'">'. $loc_phone .'</a>'; ?>

    I also need a null value so it will essentially be <?php if(SELECTED_PAGE_ID) { PHP HERE } ?> so that if nothing is selected for that page, nothing is output.

  • Here are some visuals if they help:

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

The topic ‘Create admin select list’ is closed to new replies.