Forums

Call theme options inside a template tag (2 posts)

  1. 610m
    Member
    Posted 2 years ago #

    I have a custom theme options page where I set theme specific options. I have no problem calling these options into my theme when they stand alone but I don't know how to call them inside of a template tag. For example:

    I have a field in the theme options where I can set the categories that are excluded from my category navigation. The value of this field is <?php echo get_option('exclude-cat-nav'); ?>. When I echo this in my theme it shows the numbers I enter like "2, 15, 36". How can I call this inside the wp_list_categories template tag?

    I was thinking something like this:
    <?php wp_list_categories('exclude='. exclude-cat-nav .'&title_li='); ?>

    or this:
    <?php wp_list_categories('exclude='. get_option('exclude-cat-nav') .'&title_li='); ?>

    but nothing seems to work. Can someone explain what I'm doing wrong, or just tell me how to do it?

    Thanks!

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    After doing this:

    INSERT INTO wp_options (option_id , blog_id , option_name , option_value , autoload)
    VALUES (
    NULL , '0', 'exclude-cat-nav', '3,19,17', 'yes'
    );

    this works just fine for me:
    <?php wp_list_categories('exclude='. get_option('exclude-cat-nav') .'&title_li='); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic