-
-
Save About2git/213c3b51c66626218d7a to your computer and use it in GitHub Desktop.
Replacing Genesis Featured Posts widget output with custom code
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
| //* Function to display space separated (default) category slugs | |
| function the_category_unlinked( $separator = ' ' ) { | |
| $categories = get_the_category(); | |
| $thelist = ''; | |
| foreach( $categories as $category ) { // concatenate | |
| $thelist .= $separator . $category->category_nicename; | |
| } | |
| echo $thelist; | |
| } |
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 ( ! empty( $instance['title'] ) ) | |
| echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; |
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
| genesis_widget_area( 'home-top', array( | |
| 'before' => '<div class="home-top widget-area">', | |
| 'after' => '</div>', | |
| ) ); |
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
| // WP_Query arguments | |
| $args = array ( | |
| 'post_type' => 'post', | |
| 'category_name' => 'living-in-place,middle-ages', | |
| 'posts_per_page' => '1', | |
| ); | |
| // The Query | |
| $query = new WP_Query( $args ); | |
| // The Loop | |
| if ( $query->have_posts() ) { | |
| while ( $query->have_posts() ) { | |
| $query->the_post(); ?> | |
| <div class="home-top"> | |
| <h4 class="home-top-title<?php the_category_unlinked(' '); ?>"> | |
| <?php $category = get_the_category(); ?> | |
| <?php echo $category[0]->cat_name; ?> | |
| </h4> | |
| <article itemtype="http://schema.org/BlogPosting" itemscope="itemscope"> | |
| <header class="entry-header"> | |
| <h2 class="entry-title"><a href="<?php echo get_permalink(); ?>"><?php echo get_the_title(); ?></a></h2> | |
| <p class="entry-meta"> | |
| <?php echo do_shortcode("[post_date]"); ?> | |
| <?php echo do_shortcode("[post_comments]"); ?> | |
| </p> | |
| </header> | |
| <div class="entry-content"> | |
| <?php the_content( '[Read More...]' ); ?> | |
| </div> | |
| </article> | |
| </div> | |
| <?php } | |
| } else { | |
| // no posts found | |
| } | |
| // Restore original Post Data | |
| wp_reset_postdata(); |
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
| wp_enqueue_style( 'daily-dish-google-fonts', '//fonts.googleapis.com/css?family=Alice|Lato:400,700,900', array(), CHILD_THEME_VERSION ); |
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
| wp_enqueue_style( 'daily-dish-google-fonts', '//fonts.googleapis.com/css?family=Alice|Lato:400,700,900|Satisfy|Almendra', array(), CHILD_THEME_VERSION ); |
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
| genesis_register_sidebar( array( | |
| 'id' => 'home-top', | |
| 'name' => __( 'Home - Top', 'daily-dish' ), | |
| 'description' => __( 'This is the top section of the homepage.', 'daily-dish' ), | |
| ) ); |
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
| .home-top .entry-content img { | |
| width: auto; | |
| } | |
| .daily-dish-home .home-top .entry { | |
| margin-bottom: 0; | |
| } | |
| .home-top-title { | |
| background-color: #fff; | |
| border-bottom: 1px solid #9ab45d; | |
| border-color: #9ab45d; | |
| border-width: 1px; | |
| color: #951b18; | |
| font-size: 72px; | |
| font-weight: 400; | |
| letter-spacing: 1px; | |
| margin-bottom: 30px; | |
| padding: 2px 15px 12px; | |
| text-transform: none; | |
| } | |
| .home-top-title.living-in-place { | |
| font-family: "Satisfy",cursive; | |
| } | |
| .home-top-title.middle-ages { | |
| font-family: 'Almendra', serif; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment