1

Fail #1: The hook, genesis_after_content, allows me to add content directly after the <main> tag and before the <aside> tag. So in a content first, sidebar second configuration, it would look like this:

<div class="content-sidebar-wrap">
    <main></main>
    <div class="custom-content"></div>
    <aside></aside>
</div>

Fail #2: The hook, genesis_after_content_sidebar_wrap, allows me to insert content on the outside of the parent container of <main> and <aside>. So with the same content sidebar configuration, would look like this:

<div class="content-sidebar-wrap">
    <main></main>
    <aside></aside>
</div>
<div class="custom-content"></div>

Fail #3: Using the, `genesis_after_sidebar_widget_area' wont work either and results in this configuration:

<div class="content-sidebar-wrap">
    <main></main>
    <aside>
        <div class="custom-content"></div>
    </aside>
</div>

Summary: I cannot find the hook that would allow me to add content before the closing content-sidebar-wrap tag, and after the closing <aside> tag. How would I go about accomplishing this?:

<div class="content-sidebar-wrap">
    <main></main>
    <aside></aside>
    <div class="custom-content"></div>
</div>
1

If you look in lib/structure/layout.php, towards the bottom, you'll see:

add_action( 'genesis_after_content', 'genesis_get_sidebar' );
/**
 * Output the sidebar.php file if layout allows for it.
 *
 * @since 0.2.0
 *
 * @uses genesis_site_layout() Return the site layout for different contexts.
 */
function genesis_get_sidebar() {
    $site_layout = genesis_site_layout();
    //* Don't load sidebar on pages that don't need it
    if ( 'full-width-content' === $site_layout )
        return;
    get_sidebar();
}

This adds the sidebar, at the default priority 10, to genesis_after_content.

As such, if you want to come after the sidebar, but but before the closing tag of the content-sidebar-wrap, hook your code into a later priority e.g.

add_action( 'genesis_after_content', 'gmj_add_custom_div', 15 );
/**
 * Output a custom section, after primary sidebar, but still inside the content-sidebar-wrap.
 *
 * @link http://wordpress.stackexchange.com/questions/233093/genesis-how-to-add-content-after-aside-and-before-the-content-sidebar-wrap
 */
function gmj_add_custom_div() {
    ?>
    <div class="custom-content"></div>
    <?php
}

The important difference between this, and your Fail #1, is the priority of 15.

0

I found this post in a search to see how I could accomplish this for a client project I am working on. Here is the solution that worked for me, and then use CSS to position the sidebar :

// Adds the sidebar inside the main content area
add_action('genesis_before', 'mn_sidebar_entry_content');
function mn_sidebar_entry_content() {
    remove_action('genesis_sidebar', 'genesis_do_sidebar');
    add_action('genesis_entry_content', 'genesis_do_sidebar');
}`

However, if your are just looking to match the background and keep the sidebar on the side this will work:

    .site-inner .wrap{ background-color: #fff; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.