hooks - Genesis: How to add content after aside and before the content-sidebar wrap

Fail #1: The hook, genesis_after_content, allows me to add content directly after the <main> tag and before the &l

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>

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>
Share Improve this question edited Jul 25, 2016 at 3:13 ExcellentSP asked Jul 25, 2016 at 2:41 ExcellentSPExcellentSP 1822 silver badges14 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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/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.

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; }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745194011a4616001.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信