Add ACF optons and sub options
(
function code_snippets_head() {
if( have_rows('code_snippets__head', 'option') ): ?>
<?php // loop through the rows of data
while ( have_rows('code_snippets__head', 'option') ) : the_row(); ?>
<?php the_sub_field('code', 'option'); ?>
<?php endwhile; ?>
<?php
else :
// no rows found
endif;
}
add_action( 'wp_head', 'code_snippets_head', 100 );
function code_snippets_body() {
if( have_rows('code_snippets__body', 'option') ): ?>
<?php // loop through the rows of data
while ( have_rows('code_snippets__body', 'option') ) : the_row(); ?>
<?php the_sub_field('code', 'option'); ?>
<?php endwhile; ?>
<?php
else :
// no rows found
endif;
}
add_action( 'wp_footer', 'code_snippets_body', 101 );
<?php
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Code Snippets',
'menu_title' => 'Code Snippets',
'menu_slug' => 'theme-code-snippets',
'capability' => 'edit_posts',
'icon_url' => 'dashicons-media-code',
'position' => 101,
'redirect' => true
));
acf_add_options_sub_page(array(
'page_title' => 'Code Snippets for </body> Tag',
'menu_title' => '</body> Tag',
'parent_slug' => 'theme-code-snippets',
));
acf_add_options_sub_page(array(
'page_title' => 'Code Snippets for <head> Tag',
'menu_title' => '<head> Tag',
'parent_slug' => 'theme-code-snippets',
));
}
/* For admins only
if( function_exists('acf_add_options_page') ) {
if ( current_user_can( 'administrator' ) ) {.....
ACF import file: http://dlrg.co/0U1J2z3o3s0X
*/
?>