Created
March 5, 2015 09:14
-
-
Save designbuildtest/28ca93348d446104986f to your computer and use it in GitHub Desktop.
Announcement Customizer & HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ( current_theme_supports( 'announcement' ) ) { | |
| function announcement_customizer( $wp_customize ) { | |
| $wp_customize->add_section( 'announcement', array( | |
| 'title' => __( 'Announcement' ), | |
| 'description' => __( 'A summary of this page will appear in the header area of your website.' ), | |
| 'priority' => 64, | |
| ) | |
| ); | |
| $wp_customize->add_setting( 'announcement_page', array( | |
| 'type' => 'option', | |
| 'sanitize_callback' => 'absint', | |
| ) | |
| ); | |
| $wp_customize->add_control( 'announcement_page', array( | |
| //'label' => __( 'Select a page' ), | |
| 'type' => 'dropdown-pages', | |
| 'section' => 'announcement', | |
| ) | |
| ); | |
| } | |
| add_action( 'customize_register', 'announcement_customizer' ); | |
| function announcement_html() { | |
| $page_id = get_option( 'announcement_page' ); | |
| if ( $page_id ) { | |
| $args = array( | |
| 'page_id' => $page_id, | |
| ); | |
| $primary = new WP_Query( $args ); | |
| if ( $primary->have_posts() ) : ?> | |
| <div class="announcement"> | |
| <div class="container"> | |
| <?php while ( $primary->have_posts() ) : $primary->the_post(); ?> | |
| <article><?php the_excerpt(); ?></article> | |
| <?php endwhile; ?> | |
| <?php wp_reset_postdata(); ?> | |
| </div> | |
| </div><?php | |
| endif; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment