最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Get values from an advanced custom field

programmeradmin5浏览0评论

I have an advanced custom fields field called job_type. It is a select type field so it has a number of values in the field like Contract, Freelance, Permanent etc. So I list all the jobs on a page and now I want to have exposed filters on the left where a user can choose to filter the jobs based on various fields. So for example if he chooses Freelance the page should (with ajax) show only the jobs that are of type 'Freelance'

How do I get the values from the field into a select list please?

I have an advanced custom fields field called job_type. It is a select type field so it has a number of values in the field like Contract, Freelance, Permanent etc. So I list all the jobs on a page and now I want to have exposed filters on the left where a user can choose to filter the jobs based on various fields. So for example if he chooses Freelance the page should (with ajax) show only the jobs that are of type 'Freelance'

How do I get the values from the field into a select list please?

Share Improve this question edited Jul 14, 2020 at 6:54 calvincani asked Jul 14, 2020 at 6:41 calvincanicalvincani 1011 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

If you mean an ACF select field:

<?php
$field = get_field_object('my_select');
var_dump( $field['choices'] );
?>

More info here https://www.advancedcustomfields/resources/get_field_object/

发布评论

评论列表(0)

  1. 暂无评论