• Resolved Shaunrafuse

    (@shaunrafuse)


    I’m trying to create a new sidebar but every time I make a functions.php file and insert code it always shows up on the site. Why is this happening???

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator t-p

    (@t-p)

    what theme are using?

    Why are you creating a functions.php file? At the very basic a theme is required to contain its own functions.php file. You should be adding your code into the existing file, and not creating a second one.

    Also , make sure your entering all of your php code within PHP tags (<?php ?>)

    Thread Starter Shaunrafuse

    (@shaunrafuse)

    I’m using the twenty fourteen theme, and when I open the child theme directory via FTP there is no functions.php in it.. I’ve always read that it needed to be created…

    Not in a child theme. At the most, a child theme starts with a completely blank functions.php file and only new or customised functions are ever added to it. Try reviewing child themes.

    Thread Starter Shaunrafuse

    (@shaunrafuse)

    <div id="left">
    	<?php if ( is_active_sidebar( 'sidebar-left' ) ) : ?>
    	<div id="left-sidebar" class="left-sidebar widget-area" role="complementary">
    		<?php dynamic_sidebar( 'sidebar-left' ); ?>
    	</div>
    	<?php endif; ?>
    </div>

    This is for a new file created for the sidebar called ‘sidebar-left.php’

    function mychild_widgets_init() {
    	register_sidebar( array(
    		'name'          => __( 'Left Widget Area', 'twentyfourteen' ),
    		'id'            => 'sidebar-left',
    		'description'   => __( 'Left sidebar.', 'twentyfourteen' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h1 class="widget-title">',
    		'after_title'   => '</h1>',
    	) );
    }
    add_action( 'widgets_init', 'mychild_widgets_init' );

    And that’s what I added to the ‘functions.php’ file I created. Then that text shows up on the top of the site, admin dashboard or signed out..

    You forgot to add an opening <?php at the top of your functions.php file.

    Thread Starter Shaunrafuse

    (@shaunrafuse)

    Bingo… Thanks esmi.. You’ve been a great help last couple months!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Code showing on site’ is closed to new replies.