Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add widget area to one page only
Tagged: add widget area, add widget to one page
- This topic has 4 replies, 3 voices, and was last updated 11 years ago by
Badlywired.
-
AuthorPosts
-
February 2, 2015 at 12:29 pm #139426
LeaChristine
MemberI've read and tried following other answers to this question, but cannot get it to work-- I want to add a widget area above my blog post area, but only have it appear on the page that publishes my posts. In this case, it's called "Graffiti Wall." Right now I have the widget area displaying properly, but it's also on every other page-- does anyone know how I can just single out the Graffiti wall page to display it? Thanks for any help-- here is what I have right now in my functions.php:
//* Add text section above posts
genesis_register_sidebar( array(
'id' => 'new-widget',
'name' => __( 'New Widget', 'domain' ),
'description' => __( 'Add Content Here', 'domain' ),
) );add_action( 'genesis_before_loop', 'your_widget' );
function your_widget() {
if ( comments_open() && is_active_sidebar('new-widget') ) {
genesis_widget_area( 'new-widget', array(
'before' => '<div class="new-widget widget-area">',
'after' => '</div>',
) );}
}
I have tried to add a new conditional with both if ( is_page('006') && is_active_sidebar('new-widget') ) and if ( is_page('graffiti-wall') && is_active_sidebar('new-widget') ) but neither of them worked-- they just made the widget disappear entirely.
The page ID for the graffiti wall should be 6.
Site URL:
http://www.sampleblogdesign.us/graffiti-wall/February 2, 2015 at 12:36 pm #139429LeaChristine
MemberI think I fixed it-- with this:
//* Add text section above posts
genesis_register_sidebar( array(
'id' => 'new-widget',
'name' => __( 'New Widget', 'domain' ),
'description' => __( 'Add Content Here', 'domain' ),
) );add_action( 'genesis_before_loop', 'your_widget' );
function your_widget() {
if ( is_front_page() && is_home() ) {
} elseif ( is_home() ) {
genesis_widget_area( 'new-widget', array(
'before' => '<div class="new-widget widget-area">',
'after' => '</div>',
) );}
}
February 2, 2015 at 10:37 pm #139480Lauren @ OnceCoupled
MemberCool, glad you figured this out! I was just about to share this link, which is the solution you used: http://codex.wordpress.org/Conditional_Tags#The_Blog_Page
Also, for future reference, please use code tags as anyone who copies your current code will break their site.
Properly formatted code looks like this.Best,
Lauren
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
February 3, 2015 at 8:03 am #139510LeaChristine
MemberThanks Lauren!
February 3, 2015 at 5:06 pm #139567Badlywired
MemberYour solution is correct.
It is common misunderstanding that the blog page is a page. It isn't in wordpress terms it is_home().
Even if you created a page and assign it to the blog posts (settings > readings ) I assume that is what you have the 'page' isn't really used at all.
My techy blog WordPress and stuff badlywired.com
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.