• Resolved LearningDesigner

    (@learningdesigner)


    Hey all !

    I’m working on a new theme, and I want to add a sidebar with placeable widgets.

    I’ve seen a few tutorials, but nothing seems to work.

    This is in my function.php:

    function telescope_widgets_init() {
    register_sidebar( array(
    'name' => 'Sidebar Area 1',
    'id' => 'sidebar-1',
    'description' => 'Appears in the right-side sidebar area',
    'before_widget' => '<aside>',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    
    register_sidebar( array(
    'name' => 'Sidebar Area 2',
    'id' => 'sidebar-2',
    'description' => 'Appears in the right-side sidebar area',
    'before_widget' => '<aside>',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    
    register_sidebar( array(
    'name' => 'Sidebar Area 3',
    'id' => 'sidebar-3',
    'description' => 'Appears in the right-side sidebar area',
    'before_widget' => '<aside>',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    
    register_sidebar( array(
    'name' => 'Sidebar Area 4',
    'id' => 'sidebar-4',
    'description' => 'Appears in the right-side sidebar area',
    'before_widget' => '<aside>',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    
    dynamic_sidebar( $sidebar );
    $args = array(
    	'name'          => sprintf( __( 'Sidebar %d' ), $i ),
    	'id'            => "sidebar-$i",
    	'description'   => '',
    	'class'         => '',
    	'before_widget' => '<li id="%1$s" class="widget %2$s">',
    	'after_widget'  => "</li>\n",
    	'before_title'  => '<h2 class="widgettitle">',
    	'after_title'   => "</h2>\n",
    );
    
    }
    
    add_action( 'widgets_init', 'telescope_widgets_init');

    This is on my page.php, in the code. (Cuzz that will be showing on every page)

    <?php get_header(); ?>
    
    	<main role="main">
    		<!-- section -->
    		<section>
    
    		<?php if (have_posts()): while (have_posts()) : the_post(); ?>
    
    			<!-- article -->
    
    			<div id="page-content"><div id="page-text">
    			<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    				<?php the_content(); ?>
    
    				<br class="clear">
    
    				<?php edit_post_link(); ?>
    
    			</article>
    			</div>
    			<div id="side-bar"></div>
    			</div>
    			<!-- /article -->
    
    		<?php endwhile; ?>
    
    		<?php else: ?>
    
    			<!-- article -->
    			<article>
    
    				<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
    
    			</article>
    			<!-- /article -->
    
    		<?php endif; ?>
    
    		</section>
    		<!-- /section -->
    	</main>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    I got my widgets in the dashboard > widgets, but they just don’t show up.

    Please help me on this one, it’s the final thing before the theme’s ready.

    Thank you !

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘A custom sidebar for widgets’ is closed to new replies.