On/Off button Control in functions.php



I’m tring to using OptionTree framework. But, I need help.

I created custom post types and I want to control them with theme options panel.

If user want to use one of them, he must activate it from options panel, but I can’t control it. For control using on/off button.

Functions.php: Functions.php

How can I check the button is on or off?

OptionsPanel works very well.



Functions.php: http://pastie.org/9142617


Hi there:

I don’t am programmer, I don’t can help you :’( .
your patience other author or staff can help you :wink: regards.


Im not sure how far you are in your development but I would advise using wordpress customizer for theme options. In which case below should work. If not something similar might work.

<?php if(get_option('option-name') == 1) : ?>


<?php endif; ?>


I’ve changed the code;

if (get_option_tree( ‘references’, ‘on’ )) {
require_once( get_template_directory() .’/content/references.php’ );

Activated debug mode. Now, I’m taking this message;

Call to undefined function get_option_tree() in functions.php


Never used optiontree, so Im not sure if you are doing something wrong, but it could be because you are calling the function before the OT framework is initialized. In which case, you should move option tree functions to a separate file ‘theme-functions.php’ and call the functions there. Then just require get_template_directory() . ‘/inc/theme-functions.php’ in your functions file after OT init.


OptionTree works very well…

When I use the codes fronted, it shows. The matter that I can’t use the codes in functions.php


My friend thats what I mean, you are probably writing the function before wordpress has initialized option tree framework hence get_option_tree() is an undefined function. Either move it after Option tree is initialized or move it to a separate file and require that file in your functions.php


Moved the codes to theme_setup function. Now it works.

Thanks @codeblvck.


You are welcome buddy, good luck!