• I created my own theme based on the blankslate theme and using WordPress locally on my computer. I’m trying to 2 sidebars to my webpage one that is in all the inner pages and one that is per page. I used widgets to do this because it has to be user friendly for client who doesn’t know html code.
    For the first sidebar I used the default widgets I renamed the widgets in functions.php then I added the second widgets

    register_sidebar( array (
    'name' => __( 'Main Sidebar  (for all inner pages)', 'blankslate' ),
    'id' => 'primary-widget-area',
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => "",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
    register_sidebar( array (
    'name' => __( 'Attorneys ', 'blankslate' ),
    'id' => 'primary-widget-area3',
    'before_widget' => '<div id="primary" class="widget-area2"><li id="%1$s" class="widget-container2 %2$s">',
    'after_widget' => "",
    'before_title' => '<h3 class="widget-title2">',
    'after_title' => '</h3>',
    ) );
    }
    Then I changed I moved the sidebar just below the header in page.php
    <?php get_header(); ?>
    <section id="content" role="main">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="header">
    </header>
    <?php dynamic_sidebar('primary-widget-area2'); ?>
    </div>
    <?php get_sidebar(); ?>
    <section class="entry-content">
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
    <?php the_content(); ?>
    <div class="entry-links"><?php wp_link_pages(); ?></div>
    </section>
    </article>
    <?php if ( ! post_password_required() ) comments_template( '', true ); ?>
    <?php endwhile; endif; ?>
    </section>
    <?php get_footer(); ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    This works but I have to add a widget and a page template for each inner sidebar for all each page in WordPress because the inner sidebar is page specific.
    Also if I add another widgets to the inner sidebar it messes up the main content inside the webpage.
    I really don’t know php code so you need to explain what that code does.
    Is there a better way to do this?

  • The topic ‘widgets custom theme’ is closed to new replies.