WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Theme Option Problem with WP 2.8 (8 posts)

  1. logicstar
    Member
    Posted 5 years ago #

    Hello.. I just upgrading wordpress 2.8
    i found some problem on theme option page.
    on the theme option page, When I edit the theme options and save the changes then all categories selections are gone and categories doesn't show anymore.
    is someone can help me?

    thank you

  2. logicstar
    Member
    Posted 5 years ago #

    i use my own theme,
    and this is the code of the option page (for the categories select only)

    <?php
    $themename = "My-Theme";
    $shortname = "nm";
    $nm_categories_obj = get_categories('hide_empty=0');
    $nm_categories = array();
    foreach ($nm_categories_obj as $nm_cat) {
    $nm_categories[$nm_cat->cat_ID] = $nm_cat->cat_name;
    }
    $categories_tmp = array_unshift($nm_categories, "Category Name:");
    $number_entries = array("Select a Number:","1","2","3","4","5","6");

    $options = array (

    array( "name" => "Select Category for Featured Posts",
    "id" => $shortname."_slide_category",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $nm_categories),

    if i select categories for featured posts and hit save button.
    the categories will be disapear and the it is not workin at all

  3. foxinni
    Member
    Posted 5 years ago #

    Are you using a WooTheme? We are offering support to all the themes with the new upgrades to WordPress 2.8. This happens to be one of the problems. :P

  4. logicstar
    Member
    Posted 5 years ago #

    oh no.. i use my own theme :)
    not using any WooTheme

  5. foxinni
    Member
    Posted 5 years ago #

    Well I guess I could tell you what the problem is.

    You have to wrap the entire snippet in a function, presuming that your code is in the root of your functions.php file or other.

    Then call the function on the wordpress 'init' hook, add_action('init','theme_option');

    As follow:

    <?php
    function options_function(){
    $themename = "My-Theme";
    $shortname = "nm";
    $nm_categories_obj = get_categories('hide_empty=0');
    $nm_categories = array();
    foreach ($nm_categories_obj as $nm_cat) {
    $nm_categories[$nm_cat->cat_ID] = $nm_cat->cat_name;
    }
    $categories_tmp = array_unshift($nm_categories, "Category Name:");
    $number_entries = array("Select a Number:","1","2","3","4","5","6");
    
    $options = array (
    
    array( "name" => "Select Category for Featured Posts",
    "id" => $shortname."_slide_category",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $nm_categories),
    ...
    
    update_option('theme_options',$options);
    
    }
    
    add_action('init','option_function');

    Then reference the $options like so:

    $options = get_option('theme_options');
    foreach ($option as $option){
    ...

    Hope that helps.
    WooThemes.com

  6. wpcoda
    Member
    Posted 5 years ago #

    I got the same problem...this must be a wp2.8 bug.

    anyway I found a solution...

    added this to the mytheme_add_admin function after the global declarations (I guess u r using the same options template).


    foreach (get_categories() as $cat) $cats[] = $cat->cat_name;
    $options[0]["options"] = $cats;

    Where the 0 is the position in the options array.

  7. logicstar
    Member
    Posted 5 years ago #

    thank you wpcoda,
    but it is still not working.
    the posible solution on my theme is change the "select" option into
    "write" option.
    so i change the dropdown list of catgeories into manual writing to show the categories :)

    i am still try to find best solution.

    any idea with my theme option ?

  8. logicstar
    Member
    Posted 5 years ago #

    @ foxinni ( WooThemes.com )
    awesome..it's works..
    Thank you So much for your help...

Topic Closed

This topic has been closed to new replies.

About this Topic