9 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Turkey
bsinternet says

Hello..

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.

Thanks.

9 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Turkey
bsinternet says
430 posts
  • Has sold $100+ on Envato Market
  • Located in Chile
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
NCDesigner says

Hi there:

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

140 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
codeblvck says

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) : ?> hello <?php endif; ?>

9 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Turkey
bsinternet says
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

140 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
codeblvck says

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.

9 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Turkey
bsinternet says

OptionTree works very well..

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

140 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
codeblvck says

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

9 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in Turkey
bsinternet says

Moved the codes to theme_setup function. Now it works.

Thanks @codeblvck.

140 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
codeblvck says

You are welcome buddy, good luck!

by
by
by
by
by
by