Milada Posted April 9, 2017 Share Posted April 9, 2017 Hi all, I have a sidebar which is now to the right from the articles on posts/pages (incorporated in the theme). Now I would like to add a widget sidebar that would be to the left from an article (of a post/page). To register a sidebar, I would use this code: function wpb_widgets_init() { register_sidebar( array( 'name' => __( 'Main Sidebar', 'wpb' ), 'id' => 'sidebar-1', 'description' => __( 'The main sidebar appears on the right on each page except the front page template', 'wpb' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' =>__( 'Front page sidebar', 'wpb'), 'id' => 'sidebar-2', 'description' => __( 'Appears on the static front page template', 'wpb' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } add_action( 'widgets_init', 'wpb_widgets_init' ); Then to position it to the left from an article, the CSS class should be like this?: .sidebar { float: left; margin-right: -100%; max-width: 413px; position: relative; width: 29.4118%; } Thank you in advance for your help. Milada Link to comment Share on other sites More sharing options...
Ingolme Posted April 9, 2017 Share Posted April 9, 2017 It really depends on what order the resulting elements are in the HTML and what styles have been applied to the other elements. I would not set the margin to -100%. Link to comment Share on other sites More sharing options...
Milada Posted April 12, 2017 Author Share Posted April 12, 2017 Hallo, thank you for your feedback. How do I find out about the order of the elements in HTML are and the styles? What margin would you set? Thank you in advance, Milada Link to comment Share on other sites More sharing options...
dsonesuk Posted April 12, 2017 Share Posted April 12, 2017 The layout is determined by the specific template page you use for a single post, category posts, page or archive pages, usually you would have left and right sidebar code to show when required by setting in the sidebar array the id of post or page you wish the sidebar to appear. Link to comment Share on other sites More sharing options...
Milada Posted April 15, 2017 Author Share Posted April 15, 2017 I imagine it would be axially symmetric. So to find the parameters, I look for them in the style.css? Could you specify more closely the position? Thank you. Link to comment Share on other sites More sharing options...
dsonesuk Posted April 15, 2017 Share Posted April 15, 2017 Like I said the sidebars are located in page, single or category php template files, php controls when these sidebars show, css does not control showing sidebars, it is for presentation only. Link to comment Share on other sites More sharing options...
Milada Posted April 19, 2017 Author Share Posted April 19, 2017 I have created this code: genesis_register_sidebar( array( 'id' => 'alonside-posts-sidebar', 'name' => __('Alonside Posts', 'wellness' ), 'description' => __('This is a sidebar that goes alongside the posts in the #content.' ), ) ); add_action( 'genesis_before_loop', 'wellness_alongside_posts_sidebar' ); /** Loads a new sidebar alongside the posts in the #content */ function wellness_alongside_posts_sidebar() { echo '<div class="alongside-posts-sidebar">'; dynamic_sidebar( 'alongside-posts-sidebar' ); echo '</div>'; } Can you please tell me if it´s correct? I would like to have a sidebar alongside the content on the left? What should be added? Thank you, Milada Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now