Skip to content

Instantly share code, notes, and snippets.

@imath
Created January 16, 2017 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/c47918aa0add2824b4b059178134cd3e to your computer and use it in GitHub Desktop.
Save imath/c47918aa0add2824b4b059178134cd3e to your computer and use it in GitHub Desktop.
Add a widget area above the WP Idea Stream archive page. The full child theme is available here: https://cldup.com/yk8pyyY1p1.zip
<?php
/**
* 1st step: Just register a new sidebar.
*/
function twentyseventeen_child_register_sidebar() {
register_sidebar( array(
'name' => __( 'Ideas', '2017-child' ),
'description' => __( 'Above the list of ideas', '2017-child' ),
'id' => 'ideas',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
) );
}
add_action( 'widgets_init', 'twentyseventeen_child_register_sidebar' );
<?php
/**
* 2nd step :
* - create a new template in the theme and call it "ideastream.php"
* - copy the content of the page.php template and paste it in the "ideastream.php" template
* - Edit the "ideastream.php" template as shown at lines 14 to 18
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<?php if ( is_active_sidebar( 'ideas' ) && wp_idea_stream_is_idea_archive() ) : ?>
<aside id="ideas-sidebar" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'ideas' ); ?>
</aside><!-- #ideas-sidebar -->
<?php endif ;?>
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/page/content-front', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<?php get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment