Skip to content

Instantly share code, notes, and snippets.

@About2git
Forked from srikat/functions.php
Created February 13, 2015 21:20
Show Gist options
  • Select an option

  • Save About2git/213c3b51c66626218d7a to your computer and use it in GitHub Desktop.

Select an option

Save About2git/213c3b51c66626218d7a to your computer and use it in GitHub Desktop.
Replacing Genesis Featured Posts widget output with custom code
//* 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;
}
if ( ! empty( $instance['title'] ) )
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
genesis_widget_area( 'home-top', array(
'before' => '<div class="home-top widget-area">',
'after' => '</div>',
) );
// 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();
wp_enqueue_style( 'daily-dish-google-fonts', '//fonts.googleapis.com/css?family=Alice|Lato:400,700,900', array(), CHILD_THEME_VERSION );
wp_enqueue_style( 'daily-dish-google-fonts', '//fonts.googleapis.com/css?family=Alice|Lato:400,700,900|Satisfy|Almendra', array(), CHILD_THEME_VERSION );
genesis_register_sidebar( array(
'id' => 'home-top',
'name' => __( 'Home - Top', 'daily-dish' ),
'description' => __( 'This is the top section of the homepage.', 'daily-dish' ),
) );
.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