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' );
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.