Support

Account

Home Forums ACF PRO Use value from options page in functions.php Reply To: Use value from options page in functions.php

  • This function is only running during acf/save_post, so you’re init action will never be added unless a post is being saved.

    
    <?php 
        
      function codex_custom_init() {
        $var = get_field('test_switch', 'option' );
        if($var == 'true' ) {
      
        register_post_type(
          'evenementen', array(
              'labels' => array('name' => __( 'Feesten en evenementen' ),
              'singular_name' => __( 'Feest of evenement' ),
              'add_new' => __( 'Feest of evenement toevoegen' ),
              'add_new_item' => __( 'Feest of evenement toevoegen' ),
              'edit_item' => __( 'Feest of evenement bewerken' ),
              'new_item' => __( 'Feest of evenement toevoegen' ),
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail')
           )
          );
        }
      }
      add_action( 'init', 'codex_custom_init' );
    ?>