delarge
4/14/2016 - 1:28 PM

Add ACF optons and sub options (

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 &lt;/body&gt; Tag',
      'menu_title'	=> '&lt;/body&gt; Tag',
      'parent_slug'	=> 'theme-code-snippets',
    ));


  acf_add_options_sub_page(array(
  		'page_title' 	=> 'Code Snippets for &lt;head&gt; Tag',
  		'menu_title'	=> '&lt;head&gt; 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

*/

?>