1

I'm a newbie to WordPress Development so bear with me.

Site: https://wordpress-portfolio-zacnespral21.c9.io/

On the site above I would like to add an option in the themes options page for the user to replace the brid logo(default) on the left hand side with whatever image they choose/upload. I was able to get the themes option page created and fill in some dummy content, but now im stuck. Currently the logo is being called via background-image on a span with the class of .portfolioLogo any help to get this working would be appreciated.

Thanks!

<?php

/**
* Step 1: Create link to the menu page.
*/
add_action('admin_menu', 'ss_create_menu');
function ss_create_menu() {    
    //create new top-level menu
    add_menu_page(__('Theme Settings', 'simpleandsweet'), __('S&S Theme', 'simpleandsweet'), 'administrator', 'simpleandsweet-theme-settings', 'ss_settings_page', 'dashicons-admin-generic');   
}

/**
* Step 2: Create settings fields.
*/
add_action( 'admin_init', 'register_znsettings' );
function register_znsettings() {
    register_setting( 'ss-settings-general', 'portfolioLogo' );
}

/** 
* Step 3: Create the markup for the options page
*/
function ss_settings_page() {

?>

<div class="wrap">
<h2><?php _e('Simple and Sweet - Theme Settings', 'S&S Themes'); ?></h2>

    <form method="post" id="ss-theme-options" action="options.php">

        <?php if(isset( $_GET['settings-updated'])) { ?>
        <div class="updated">
            <p><?php _e('Settings updated successfully', $textdomain); ?></p>
        </div>
        <?php } ?>

        <table class="form-table">
            <tr><td colspan="2"><h3><?php _e('Current Site Logo', 'simpleandsweet'); ?></h3></td></tr>

            <tr valign="top">
                <th scope="row"><?php _e('Logo', 'simpleandsweet'); ?></th>
                <td>
                    <img src="" alt="" />
                </td>
            </tr>

            <?php settings_fields( 'ss-settings-general' ); ?>
            <?php do_settings_sections( 'ss-settings-general' ); ?>
        </table>

        <?php submit_button(); ?>
    </form>

</div>
1

what framework do you use for your theme-panel?

You need to make image upload into your theme panel page and a line of code to call it everywhere of your theme you want.

This is an example:

in theme panel function page

$options[] = array(
        'name' => __('Introduction Image', 'options_check'),
        'desc' => __('This is your site logo.', 'options_check'),
        'id' => 'introtext_uploader',
        'type' => 'upload');

and into your theme e.g header.php

<img src="<?php echo of_get_option('introtext_uploader'); ?>" alt="" />
  • Im confused when you say "What framework do I use" so ive updated my question with the code from my theme-options page, i tried what you said but i dont believe i did it right, so im giving you the code that currently works instead. – ZacNespral21 May 26 '15 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.