9 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • 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
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Turkey
bsinternet says
430 posts
  • Bought between 10 and 49 items
  • Chile
  • Exclusive Author
  • Has been a member for 0-1 years
  • Sold between 100 and 1 000 dollars
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
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Referred between 1 and 9 users
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • United Kingdom
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
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • 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
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Referred between 1 and 9 users
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • United Kingdom
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
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • 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
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Referred between 1 and 9 users
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • United Kingdom
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
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Turkey
bsinternet says

Moved the codes to theme_setup function. Now it works.

Thanks @codeblvck.

140 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Referred between 1 and 9 users
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • United Kingdom
codeblvck says

You are welcome buddy, good luck!

by
by
by
by
by
by