Grow your CSS skills. Land your dream job.

WordPress Theme Option Problem

  • # October 15, 2012 at 10:30 pm

    Hi,

    I’m having some problems with my theme-options.php & now I’m unable to edit any of appearance options nor the website opens .
    My WordPress Site:
    http://www.dryerventcleaninghouston.com/

    This is where the error occurs:

    < ?php _e("Homepage Featured Left", 'studiopress'); ?>

    < ?php _e("Select which category you want displayed:", 'studiopress'); ?>

    < ?php wp_dropdown_categories(array('selected' => get_theme_mod(‘featured_top_left’), ‘name’ => $settings.’[featured_top_left]‘, ‘orderby’ => ‘Name’ , ‘hierarchical’ => 1, ‘hide_empty’ => ‘0’ )); ?>

    < ?php _e("Number of posts to show:", 'studiopress'); ?>

    # October 15, 2012 at 11:17 pm

    @Tahirk What is on line 88?

    Shouldn’t it be

    `< ?php wp_dropdown_categories(array('selected' => get_theme_mod(‘featured_top_left’), ‘name’ => $settings, ‘orderby’ => ‘Name’ , ‘hierarchical’ => 1, ‘hide_empty’ => ‘0’ )); ?>`

    # October 15, 2012 at 11:35 pm

    Thanks Christopher. On line 88 I have this:

    # October 15, 2012 at 11:37 pm

    @tahirk Hmm. Try my suggestion above. If that doesn’t work, keep the change but also try this:

    `

    # October 16, 2012 at 12:06 am

    Thanks a lot for your help, I’m still facing some problems:

    Basically at first I was having some problems with setting the number of posts to show as they would reset to 3 as soon as I set it to 5. So I tried to edit & it bite me back.

    # October 16, 2012 at 12:12 am


    < ?php
    /*
    Plugin Name: Theme Options
    Author: Nathan Rice
    Author URI: http://www.nathanrice.net/

    NOTE: this file requires WordPress 2.7+ to function
    */
    $settings = 'mods_'.get_current_theme(); // do not change!

    $defaults = array( // define our defaults
    'header_blog_title' => 'Image',
    'featured_top_left' => 1,
    'featured_top_left_num' => 5,
    'featured_top_left_thumb_width' => 100,
    'featured_top_left_thumb_height' => 100,
    'blog_cat' => 1,
    'blog_cat_num' => 5 // < -- no comma after the last option
    );

    // push the defaults to the options database,
    // if options don't yet exist there.
    add_option($settings, $defaults, '', 'yes');

    /*
    ///////////////////////////////////////////////
    This section hooks the proper functions
    to the proper actions in WordPress
    \\\\\\\\\\\\\\\\\\\\\\\
    */
    // this function registers our settings in the db
    add_action('admin_init', 'register_theme_settings');
    function register_theme_settings() {
    global $settings;
    register_setting($settings, $settings);
    }
    // this function adds the settings page to the Appearance tab
    add_action('admin_menu', 'add_theme_options_menu');
    function add_theme_options_menu() {
    add_submenu_page('themes.php', 'Education '.__('Theme Options','studiopress'), 'Education '.__('Theme Options','studiopress'), 8, 'theme-options', 'theme_settings_admin');
    }

    /*
    ///////////////////////////////////////////////
    This section handles all the admin page
    output (forms, update notifications, etc.)
    \\\\\\\\\\\\\\\\\\\\\\\
    */
    function theme_settings_admin() { ?>
    < ?php theme_options_css_js(); ?>

    < ?php
    // display the proper notification if Saved/Reset
    global $settings, $defaults;
    if(get_theme_mod('reset')) {
    echo '

    '.__('Theme Options', 'studiopress').' '.__('RESET TO DEFAULTS', 'studiopress').'

    ';
    update_option($settings, $defaults);
    } elseif($_REQUEST == 'true') {
    echo '

    '.__('Theme Options', 'studiopress').' '.__('SAVED', 'studiopress').'

    ';
    }
    // display icon next to page title
    screen_icon('options-general');
    ?>

    < ?php echo get_current_theme() . ' '; _e('Theme Options', 'studiopress'); ?>



    < ?php settings_fields($settings); // important! ?>

    < ?php // first column ?>


    < ?php _e("Header Blog Title"); ?>



    < ?php _e("Select from the following:", 'studiopress'); ?>






    < ?php _e("Homepage Featured Left", 'studiopress'); ?>



    < ?php _e("Select which category you want displayed:", 'studiopress'); ?>

    < ?php wp_dropdown_categories(array('selected' => get_theme_mod('featured_top_left'), 'name' => $settings, 'orderby' => 'Name' , 'hierarchical' => 1, 'hide_empty' => '0' )); ?>



    < ?php _e("Number of posts to show:", 'studiopress'); ?>



    < ?php _e("Thumbnail dimensions (Width x Height)", 'studiopress'); ?>

    x






    < ?php _e("Blog Page Template", 'studiopress'); ?>



    < ?php _e("Select which category you want displayed:", 'studiopress'); ?>

    < ?php wp_dropdown_categories(array('selected' => get_theme_mod('blog_cat'), 'name' => $settings.'[blog_cat]', 'orderby' => 'Name' , 'hierarchical' => 1, 'show_option_all' => __("All Categories", 'studiopress'), 'hide_empty' => '0' )); ?>



    < ?php _e("Number of Posts to Show:", 'studiopress'); ?>

















    < ?php }

    // add CSS and JS if necessary
    function theme_options_css_js() {
    echo < <


    CSS;
    echo < <


    JS;
    }
    ?>

    # October 16, 2012 at 12:27 am

    May I ask why you’re editing a plugin file? This is usually not recommended. Plus, `'[]’` seems to happen a lot in that code. From the very little knowledge I have with PHP, I thought it was supposed to go like this: “

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".