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
476 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.

213 posts
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
+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

213 posts
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
+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

213 posts
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
+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.

213 posts
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
+2 more
codeblvck says

You are welcome buddy, good luck!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by