WordPress.org

Ready to get started?Download WordPress

Forums

Content Aware Sidebars
[resolved] Adding Sidebar to Theme without Sidebars (4 posts)

  1. annaslipp
    Member
    Posted 1 year ago #

    I have a theme that I really like for my blog (www.pethealthadvocate.me), but it has no sidebars. I'm hoping to use this plug-in to add a news roll of updates from FDA on the home/landing page of the blog. I used this plug-in for a different site, which had header and footer navigation "sidebars", which I could "replace" with your plug-in sidebars, but I don't have that option with this theme for some reason. The header/footer areas are only for menus/navigation, and there is literally no place to add widgets.

    Is there a way to use this plug-in if there is no built-in sidebar, header or footer area, which accepts widgets? If so, please advise. My coding ability is limited, at best, so if I need to adjust the css, please be specific about what needs to go where in the theme editor.

    Thank you!

    http://wordpress.org/extend/plugins/content-aware-sidebars/

  2. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    There are two possibilites to solve this:

    1. You create and insert ordinary sidebars in your theme and uses Content Aware Sidebars to merge with or replace these sidebars.

    2. You insert display_ca_sidebar( $args ) in your theme to create content aware sidebars that are handled manually (i.e. they do not replace or merge with other sidebars).

    I would suggest option 1, but let me know which one you choose and I'll help you further.

  3. annaslipp
    Member
    Posted 1 year ago #

    Option one sounds preferable. This plug-in is brilliant on the theme I have that has a built-in side bar, so just replicating that format would be wonderful.

    I've searched the wordpress codex to find "how to add sidebar" links, but it assumes that the person reading the proposed code knows where to actually insert the code. (I can make minor code/template changes, but only to things like color, margin, padding, etc.)

    Any thoughts you may have would be very helpful.

    Thank you again! - Anna

  4. Joachim Jensen (Intox Studio)
    Member
    Plugin Author

    Posted 1 year ago #

    In the Theme Editor, go to Theme Functions and insert the following:

    add_action( 'widgets_init', 'my_register_sidebars' );
    function my_register_sidebars() {
    	register_sidebar(
    		array(
    			'id' => 'primary',
    			'name' => __( 'Primary' ),
    			'before_widget' => '<div id="%1$s" class="widget %2$s">',
    			'after_widget' => '</div>',
    			'before_title' => '<h3 class="widget-title">',
    			'after_title' => '</h3>'
    		)
    	);
    }

    Notice that you can alter the HTML in the properties.

    In the Theme Template where you want to insert the sidebar, e.g. in the footer, insert the following at the preferred spot:

    <?php if(is_active_sidebar('primary')) : ?>
    <div id="sidebar">
    <ul>
    <?php dynamic_sidebar('primary'); ?>
    </ul>
    </div>
    <?php endif; ?>

    Again, you can change the HTML.

    Go to the Controlpanel > Widgets and drag some widgets to the sidebar so that it becomes active and you can style it with CSS.

    Now you can create new content aware sidebars that use this sidebar as a host.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic