2016-05-05 6 views
0

habe ich diesen Code in meine functions.phperhalten ACF Felder aus PHP-Datei

include_once('advanced-custom-fields/acf.php'); 
include_once('acf-options-page/acf-options-page.php'); 
include_once('acf-repeater/acf-repeater.php'); 
define('ACF_LITE', true); 

if(function_exists("register_field_group")) 
{ 

    register_field_group(array (
     'id' => 'acf_options', 
     'title' => 'Options', 
     'fields' => array (
      array (
       'key' => 'field_525d1b6d49043', 
       'label' => 'lable', 
       'name' => 'homepage', 
       'type' => 'repeater', 
       'instructions' => 'Select which categories you want to display on the homepage.', 
       'sub_fields' => array (
        array (
         'key' => 'field_525d1b8a49044', 
         'label' => 'Category', 
         'name' => 'firsttext', 
         'type' => 'text', 
         'column_width' => '', 
         'field_type' => 'text', 
         'return_format' => 'id', 
        ), 
        array (
         'key' => 'field_525d2473de72c', 
         'label' => 'Number of Posts', 
         'name' => 'number-of-posts', 
         'type' => 'text', 
         'column_width' => '', 
         'default_value' => 4, 
         'placeholder' => '', 
         'prepend' => '', 
         'append' => '', 
         'min' => 2, 
         'max' => '', 
         'step' => 2, 
        ), 
       ), 
       'row_min' => 1, 
       'row_limit' => 1, 
       'layout' => 'row', 
       'button_label' => 'Add a category', 
      ), 


     ), 
     'location' => array (
      array (
       array (
        'param' => 'options_page', 
        'operator' => '==', 
        'value' => 'acf-options', 
        'order_no' => 0, 
        'group_no' => 0, 
       ), 
      ), 
     ), 
     'options' => array (
      'position' => 'normal', 
      'layout' => 'no_box', 
      'hide_on_screen' => array (
      ), 
     ), 
     'menu_order' => 0, 
    )); 
} 

Dann habe ich Werte in die Felder Admin-Konsole

Wie ich Katze erhalten diesen Wert aus der Auslagerungsdatei eingeben?

Ich versuche Get_Field (‚acf_options) und ich versuche Get_Field (‘ Homepage), aber diese Rückkehr null

Antwort

0

Im nicht sicher, warum wollen Sie diese stattdessen in Ihrer function.php Datei setzen, diese dies nur tun durch das Plugin.

Aber wenn Sie diese Feldwerte abrufen möchten, sollten Sie dies tun: get_field('homepage', 'option'); statt: get_field('homepage') oder get_field('acf_options');

Mein bester Rat wäre, auf die ACF website für Informationen zu schauen. Diese Dokumente helfen viel!

+0

Ihr anwer reslove mein problem Vielen Dank! – user2989927