Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 512573

Inserting a widget area inside content area, but before a “related posts” plugin

$
0
0

Replies: 0

In my posts, I’m using a Zemanta related posts plug-in. It hooks into my site using this:

add_filter('the_content', 'zem_rp_add_related_posts_hook', 10);

I want to put a widget area above it so I can put some of my own ads in every post after the content but before Zemanta.

My code is this:

// Register ad spot for inside lower content area
    register_sidebar( array(
            'name' => __( 'In-Content Space', 'tto' ),
            'id' => 'in-content-ad-space',
            'description' => __( 'IN-CONTENT AD SPACE. Puts content above the Zemanta area.', 'tto' ),
            'before_widget' => '<aside id="%1$s" class="widget %2$s">',
            'after_widget' => '</aside>',
            'before_title' => '<h3 class="widget-title">',
            'after_title' => '</h3>',
    ) );

add_filter('the_content', 'sb_in_content_widget', 9 );
function sb_in_content_widget () { ?>

            <div class="in-content">
                 <?php if ( is_active_sidebar( 'in-content-ad-space' ) ) : ?>
                       <?php dynamic_sidebar( 'in-content-ad-space' ); ?>
                 <?php endif; ?>
           </div><!-- .in-content-->
}

Note that I’m using a priority of 9 to put it before Zemanta.

I created a text widget with sample text to try it. When I try it, my post content disappears with my Zemanta box. All that shows is my test widget, then the comments block.

What am I missing here? Using add_filter should add my widget area into the content, not replace it. Zemanta uses add_filter to get in there without a problem.


Viewing all articles
Browse latest Browse all 512573

Trending Articles