Skip to content

Instantly share code, notes, and snippets.

@nishit-pugmarker
Last active June 24, 2022 06:12
Show Gist options
  • Save nishit-pugmarker/5afabc049367f83eebbab665b3612e52 to your computer and use it in GitHub Desktop.
Save nishit-pugmarker/5afabc049367f83eebbab665b3612e52 to your computer and use it in GitHub Desktop.
the_field : It works without echo / print command
example
<?php the_field('buy_mangoes_directly_from_devgad_farmers_association'); ?>
Work with echo / print
<?php echo get_field('banner_emblem'); ?>
Repeater :
<?php
if (have_rows('devgad_mango_features')):
while (have_rows('devgad_mango_features')): the_row();
$feature_content = get_sub_field('feature_content');
echo $feature_content;
endwhile;
endif;
?>
Count of repeter field
<?php
$count=count(get_field('how_does'));
?>
For Image:
<?php echo wp_get_attachment_image(get_field('banner_image'),"full");?>
//Define Option page in functions.php file
// More details can be found : https://www.advancedcustomfields.com/resources/options-page/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
//For fetch value code will be similar to above only option parameter will be passed
//Example:
<?php the_field('header_title', 'option'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment