Sidebar class depending on post format of 1st post
-
I’m certainly no expert on PHP, but I’m attempting to create some conditional logic in sidebar.php to change the CSS class of the sidebar based on the post format of the 1st page.
Here is what I have so far:
if ( 'content' != $current_layout ) : ?> <?php if( $wp_query->current_post == 0 && !is_paged() ) : ?> <?php if ( has_post_format('video')) :?> <div id="secondary" class="widget-area" role="complementary"> <?php else: ?> <div id="secondary" class="widget-area" role="complementary"> <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?> <aside id="archives" class="widget"> <h3 class="widget-title"><?php _e( 'Archives', 'twentyeleven' ); ?></h3> <ul> <?php wp_get_archives( array( 'type' => 'monthly' ) ); ?> </ul> </aside> <aside id="meta" class="widget"> <h3 class="widget-title"><?php _e( 'Meta', 'twentyeleven' ); ?></h3> <ul> <?php wp_register(); ?> <li><?php wp_loginout(); ?></li> <?php wp_meta(); ?> </ul> </aside> <?php endif; // end sidebar widget area ?> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div><!-- #secondary .widget-area -
As you can see I’m trying to change the CSS class for the sidebar based on whether or not the 1st post on the blog is in the video format.
Any help or advice would be greatly appreciated!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sidebar class depending on post format of 1st post’ is closed to new replies.