WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help needed for custom header (2 posts)

  1. AlikaIsMyName
    Member
    Posted 1 month ago #

    Hello everyone,

    I was doing good then i did something stupid and now it's giving me an error. I am wondering what I did. If you can help please let me know.

    I did something to this page below:

    [please use the 'code' button to mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code
    the code below might be corrupted.]

    <?php
    /**
     * Add-on to functions.php file with functions that used for styling header.
     */
    
    /**
     * Sets up the WordPress core custom header arguments and settings.
     */
    add_action( 'after_setup_theme', function() {
        $args = array(
            'default-text-color'     => '444',
            'default-image'          => get_template_directory_uri() . '/images/logo.png',
            /* Callbacks for styling the header and the admin preview. */
            'wp-head-callback'       => 'smr_custom_header_style',
            'admin-head-callback'    => 'smr_custom_header_admin_header_style',
            'admin-preview-callback' => 'smr_custom_header_admin_header_image',
        );
    
        add_theme_support( 'custom-header', $args );
    });
    
    /**
     * Callback function:
     * Styles the header text displayed on the blog.
     *
     * get_header_textcolor() options: 444 is default, hide text (returns 'blank'), or any hex value.
     */
    function smr_custom_header_style() {
        $text_color = get_header_textcolor();
    
        /* If no custom options for text are set, let's bail */
        if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
            return;
    
        /* If we get this far, we have custom styles. */
    ?>
        <style type="text/css">
            <?php /* Has the text been hidden? */ ?>
            <?php if ( ! display_header_text() ) : ?>
                .site-title,
                .site-description { position: absolute !important; clip: rect(1px 1px 1px 1px); /* IE7 */ clip: rect(1px, 1px, 1px, 1px); }
            <?php /* If the user has set a custom color for the text, use that */ ?>
            <?php else: ?>
                #site-title a, #tagline { color: #<?php echo $text_color; ?> !important; }
            <?php endif; ?>
        </style>
    <?php
    }
    
    /**
     * Callback function:
     * Styles the header image displayed on the Appearance > Header admin panel.
     */
    function smr_custom_header_admin_header_style() {
    ?>
        <style>
            img {
                width: auto\9;
                height: auto;
                max-width: 100%;
                vertical-align: middle;
                border: 0;
                -ms-interpolation-mode: bicubic;
            }
            #header-container { width: 462px; }
            .logo-container { width: 462px; padding: 17px 0; margin-bottom: 19px; text-align: center; }
            #site-title { margin-bottom: 10px; }
            #site-title a { font-size: 50px; color: #363f4a; }
            #site-title a:hover { text-decoration: none; }
            #tagline { margin-bottom: 10px; }
            .center { text-align: center; }
        </style>
    <?php
    }
    
    /**
     * Callback function:
     * Outputs markup to be displayed on the Appearance > Header admin panel.
     * This callback overrides the default markup displayed there.
     */
    function smr_custom_header_admin_header_image() {
    ?>
        <div id="header-container">
            <div class="logo-container">
                <?php $header_image = get_header_image(); ?>
                <?php if ( ! empty( $header_image ) ) : ?>
                    <img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
                <?php endif; ?>
            </div>
            <?php
                if ( ! display_header_text() )
                    $style = ' style="display:none;"';
                else
                    $style = ' style="color:#' . get_header_textcolor() . ';"';
            ?>
            <div id="site-title" class="center"><a> onclick="return false;" href="<?php echo esc_url( home_url('/') ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo('name'); ?></a></div>
            <div id="tagline" class="center" id="desc"<?php echo $style; ?>><?php bloginfo('description'); ?></div>
        </div>
    <?php
    }

    and now I get this message below:

    Parse error: syntax error, unexpected 'else' (T_ELSE) in /home3/alika/public_html/healthybeginsnow.com/wp-content/themes/SmartReviewer/inc/functions-custom-header.php on line 42

    Please if anyone can help me it would be greatly appreciated so i can continue building my website. Thank You!!

  2. AlikaIsMyName
    Member
    Posted 1 month ago #

    nevermind just messed around and uploaded the same file via FileZilla. Works like a charm. Learn from trial and error is probably the best way. Thanks guys.

Reply

You must log in to post.

About this Topic