当前位置: 首页>>代码示例>>PHP>>正文


PHP acf_get_fields_by_id函数代码示例

本文整理汇总了PHP中acf_get_fields_by_id函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_get_fields_by_id函数的具体用法?PHP acf_get_fields_by_id怎么用?PHP acf_get_fields_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了acf_get_fields_by_id函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mb_fields

 function mb_fields()
 {
     // global
     global $post;
     // vars
     $field_group = acf_get_field_group($post);
     // get fields
     $view = array('fields' => acf_get_fields_by_id($field_group['ID']));
     // load view
     acf_get_view('field-group-fields', $view);
 }
开发者ID:eea76,项目名称:hammer,代码行数:11,代码来源:field-group.php

示例2: acf_get_fields

function acf_get_fields($parent = false)
{
    // allow $parent to be a field group ID
    if (!is_array($parent)) {
        $parent = acf_get_field_group($parent);
    }
    // bail early if no parent
    if (!$parent) {
        return false;
    }
    // vars
    $fields = array();
    // try JSON before DB to save query time
    if (acf_have_local_fields($parent['key'])) {
        $fields = acf_get_local_fields($parent['key']);
    } else {
        $fields = acf_get_fields_by_id($parent['ID']);
    }
    // filter
    $fields = apply_filters('acf/get_fields', $fields, $parent);
    // return
    return $fields;
}
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:23,代码来源:api-field.php

示例3: acf_import_field_group

function acf_import_field_group($field_group)
{
    // vars
    $ref = array();
    $order = array();
    // extract fields
    $fields = acf_extract_var($field_group, 'fields');
    // format fields
    $fields = acf_prepare_fields_for_import($fields);
    // remove old fields
    if ($field_group['ID']) {
        $db_fields = acf_get_fields_by_id($field_group['ID']);
        $db_fields = acf_prepare_fields_for_import($db_fields);
        // get field keys
        $keys = array();
        foreach ($fields as $field) {
            $keys[] = $field['key'];
        }
        // loop over db fields
        foreach ($db_fields as $field) {
            // add to ref
            $ref[$field['key']] = $field['ID'];
            if (!in_array($field['key'], $keys)) {
                acf_delete_field($field['ID']);
            }
        }
    }
    // save field group
    $field_group = acf_update_field_group($field_group);
    // add to ref
    $ref[$field_group['key']] = $field_group['ID'];
    // add to order
    $order[$field_group['ID']] = 0;
    // add fields
    foreach ($fields as $field) {
        // add ID
        if (!$field['ID'] && isset($ref[$field['key']])) {
            $field['ID'] = $ref[$field['key']];
        }
        // add parent
        if (empty($field['parent'])) {
            $field['parent'] = $field_group['ID'];
        } elseif (isset($ref[$field['parent']])) {
            $field['parent'] = $ref[$field['parent']];
        }
        // add field menu_order
        if (!isset($order[$field['parent']])) {
            $order[$field['parent']] = 0;
        }
        $field['menu_order'] = $order[$field['parent']];
        $order[$field['parent']]++;
        // save field
        $field = acf_update_field($field);
        // add to ref
        $ref[$field['key']] = $field['ID'];
    }
    // return new field group
    return $field_group;
}
开发者ID:kochira,项目名称:competstrat,代码行数:59,代码来源:api-field-group.php

示例4: get_the_field


//.........这里部分代码省略.........
         case 'image-description':
             $image_field_name = substr($field, 6);
             // Remove "image-"
             $result = self::wp_get_featured_image_field($post_id, $image_field_name);
             break;
         case 'thumbnail':
             // thumbnail
         // thumbnail
         case 'thumbnail-link':
             // thumbnail with link to post
         // thumbnail with link to post
         case 'thumbnail-link-self':
             // thumbnail with link to attachment page
             $parameters['size'] = isset($parameters['size']) && !empty($parameters['size']) ? $parameters['size'] : 'thumbnail';
             if (empty($attr['alt'])) {
                 $attr['alt'] = self::wp_get_featured_image_field($post_id, 'alt');
             }
             $result = get_the_post_thumbnail($post_id, $parameters['size'], $attr);
             break;
         case 'thumbnail-url':
             $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'thumbnail');
             $result = $src['0'];
             break;
         case 'tags':
             $result = implode(' ', wp_get_post_tags($post_id, array('fields' => 'names')));
             break;
         case 'gallery':
             // Get specific image from gallery field
             if (class_exists('CCS_Gallery_Field')) {
                 // Check if gallery field is enabled
                 $attachment_ids = CCS_Gallery_Field::get_image_ids($post_id);
                 if (empty($parameters['num'])) {
                     $parameters['num'] = 1;
                 }
                 if (empty($parameters['size'])) {
                     $parameters['size'] = 'full';
                 }
                 $result = wp_get_attachment_image($attachment_ids[$parameters['num'] - 1], $parameters['size'], $icon = false, $attr);
             }
             break;
         case 'excerpt':
             // Get excerpt
             //        $result = get_the_excerpt();
             $result = $post->post_excerpt;
             if (empty($result)) {
                 // If empty, get it from post content
                 $result = $post->post_content;
                 if (empty($parameters['words']) && empty($parameters['length'])) {
                     self::$parameters['words'] = 25;
                 }
             }
             break;
         case 'debug':
             ob_start();
             echo '<pre>';
             print_r(get_post_custom($post_id));
             echo '</pre>';
             if (function_exists('acf_get_fields_by_id')) {
                 echo '<pre>';
                 print_r(acf_get_fields_by_id($post_id));
                 echo '</pre>';
             }
             $result = ob_get_clean();
             break;
         case 'loop-count':
             $result = CCS_Loop::$state['loop_count'];
             break;
         default:
             /*---------------------------------------------
              *
              * Custom field
              *
              */
             if (!empty($parameters['custom']) && $parameters['custom'] == 'true') {
                 $field = $custom;
             }
             $result = get_post_meta($post_id, $field, true);
             if (is_numeric($result) && !empty($parameters['return'])) {
                 if ($parameters['return'] == 'page-link') {
                     // ACF page link: get URL from post ID
                     $result = get_permalink($result);
                 } else {
                     // Get attachment field
                     $parameters['id'] = $result;
                     $parameters['field'] = $parameters['return'];
                     $result = self::get_the_attachment_field($parameters);
                 }
             } elseif (!empty($parameters['property']) && is_object($result)) {
                 $result = self::get_object_property($result, $parameters['property']);
             } elseif (!empty($parameters['currency']) || !empty($parameters['decimals']) || !empty($parameters['point']) || !empty($parameters['thousands'])) {
                 $currency = !empty($parameters['currency']) ? $parameters['currency'] : '';
                 $decimals = !empty($parameters['decimals']) ? $parameters['decimals'] : 2;
                 $point = !empty($parameters['point']) ? $parameters['point'] : '.';
                 $thousands = !empty($parameters['thousands']) ? $parameters['thousands'] : ',';
                 $result = CCS_Format::getCurrency($result, $currency, $decimals, $point, $thousands);
             }
             break;
     }
     return $result;
 }
开发者ID:surreal8,项目名称:wptheme,代码行数:101,代码来源:content.php

示例5: mb_fields

 function mb_fields()
 {
     // global
     global $field_group;
     // get fields
     $view = array('fields' => acf_get_fields_by_id($field_group['ID']), 'parent' => 0);
     // load view
     acf_get_view('field-group-fields', $view);
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:9,代码来源:field-group.php


注:本文中的acf_get_fields_by_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。