Community Forums › Forums › Archived Forums › General Discussion › Advanced Field PHP Error
Tagged: ACF, Magazine Pro
- This topic has 4 replies, 3 voices, and was last updated 7 years, 7 months ago by Brad Dalton.
-
AuthorPosts
-
August 24, 2016 at 9:57 am #191946Saqib AliMember
I'm porting over a bespoke template page from my current site http://www.britishhomeopathic.org/research-reports to a local site I'm developing.
But I receive this error
FATAL ERROR: CALL TO UNDEFINED FUNCTION GET_FIELD_OBJECT() IN C:\USERS\SAQIB\DOCUMENTS\WEBSITES\WWW.BRITISHHOMEOPATHIC-SLIDER-TEST.DEV\WP-CONTENT\THEMES\MAGAZINE-PRO\REPORTSFILTER.PHP ON LINE 172
$field = get_field_object($field_key);
And when I comment this line out I receive yet another error.
But I receive this error
FATAL ERROR: CALL TO UNDEFINED FUNCTION GET_FIELD_OBJECT() IN C:\USERS\SAQIB\DOCUMENTS\WEBSITES\WWW.BRITISHHOMEOPATHIC-SLIDER-TEST.DEV\WP-CONTENT\THEMES\MAGAZINE-PRO\REPORTSFILTER.PHP ON LINE 192
$field2 = get_field_object($field2_key);`
` <?php
// Show the condition options in a dropdown box
$field_key = "field_52d684eaf18a3";
$field = get_field_object($field_key);
if($field) {
echo '<select name="', $field['key'] ,'" class="textinput textinput-r">';
// Create a default "ALL" option
echo '<option value="all">ALL</option>';
// Show all of the other options
foreach($field['choices'] as $k => $v) {
echo '<option value="', $k ,'"', (($condition == $k) ? "selected=\"selected\"" : "") ,'>', $v ,'</option>';
}
echo '</select>';
}
?>
</div>
</div>
<div class="form-line">
<label class="label">Research Type:</label>
<div class="controls">
<?php
// Show the research options in a dropdown box
$field2_key = "field_52d684ecf18a4";
$field2 = get_field_object($field2_key);
if($field2) {
echo '<select name="', $field2['key'] ,'" class="textinput textinput-r">';
// Create a default "ALL" option
echo '<option value="all">ALL</option>';
// Show all of the other options
foreach($field2['choices'] as $k => $v) {
echo '<option value="', $k ,'"', (($research == $k) ? "selected=\"selected\"" : "") ,'>', $v ,'</option>';
}
echo '</select>';
}
?>`Here is the full PHP script http://pastebin.com/mKyXF8rV
//* Research Reports Template register_post_type( 'research_report', array( 'labels' => array( 'name' => __( 'Reports' ), 'singular_name' => __( 'Report' ) ), 'public' => true, 'has_archive' => true, ) );
August 24, 2016 at 10:13 am #191949Saqib AliMemberThis is the PHP which references the page in the functions.php file
//* Research Reports Template register_post_type( 'research_report', array( 'labels' => array( 'name' => __( 'Reports' ), 'singular_name' => __( 'Report' ) ), 'public' => true, 'has_archive' => true, ) );
August 24, 2016 at 10:13 am #191950Victor FontModeratorIs ACF loaded? The get_field_object is a function of the Advanced Custom Fields plugin.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 24, 2016 at 10:19 am #191952Saqib AliMemberOnce again Victor to the rescue! I needed to enable the Advanced Custom Fields plugin.
Cheers!
August 27, 2016 at 11:12 am #192138Brad DaltonParticipant -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.