0

Genesis Grid Loop

New in Genesis 1.5

CSS:

/* Featured Post Grid
------------------------------------------------------------ */

.genesis-grid-even {
    float: right;
    padding: 0 0 15px;
    width: 48%;
}

.genesis-grid-odd {
    clear: both;
    float: left;
    padding: 0 0 15px ;
    width: 48%;
}

.genesis-grid-even,
.genesis-grid-odd {
    margin: 0 0 20px;
}

PHP:

/* functions.php:
------------------------------------------------------------ */

add_image_size('grid-thumbnail', 100, 100, TRUE);

/* home.php:
------------------------------------------------------------ */

<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'pretty_grid_loop_helper' );
/** Add support for Genesis Grid Loop **/
function pretty_grid_loop_helper() {
    if ( function_exists( 'genesis_grid_loop' ) ) {
        genesis_grid_loop( array(
            'features' => 2,
            'feature_image_size' => 0,
            'feature_image_class' => 'alignleft post-image',
            'feature_content_limit' => 0,
            'grid_image_size' => 'grid-thumbnail',
            'grid_image_class' => 'alignleft post-image',
            'grid_content_limit' => 0,
            'more' => __( '[Continue reading...]', 'genesis' ),
            'posts_per_page' => 6,
        ) );
    } else {
        genesis_standard_loop();
    }
}

/** Remove the post meta function for front page only **/
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );

genesis();

/*
Understanding the Parameters
------------------------------------------------------------ *//*

‘features’
This is the number of posts that will show at the top of the page.

‘feature_image_size’
This is the size of the featured image in the features section to be shown (set to 0, which will return no image).

‘feature_image_class’
This is where classes are assigned to the featured image in the features section which can be used for styling.

‘feature_content_limit’
This is where you can specify the number of characters of the post to show in the features section (set to 0, which will return the full content).

‘grid_image_size’
This is the size of the image in the grid section to be shown (set to 0, which will return nothing).

‘grid_image_class’
This is where classes are assigned to the featured image in the grid section which can be used for styling.

‘grid_content_limit’
This is where you can specify the number of characters of the post to show in the grid section (set to 0, which will return the post excerpt).

‘more’
This is where you can specify the text that is displayed when using the content limit option.

‘posts_per_page’
This is were you can determine how many posts are shown on each page.
*/
0

Change Login Page Logo

<?php
/**
 * Change the logo on the login page. Make the image no wider than 320px and no taller than 82px.
 */
function custom_login_logo() { ?>

h1 a { background: url(/custom/images/logo_login.png) 50% 50% no-repeat !important; }
<?php
}
add_action('login_head', 'custom_login_logo');

/**
 * Change where the logo on the login page links to
 */
function custom_login_headerurl($url) {
  return bloginfo('url') . '/';
}
add_filter('login_headerurl', 'custom_login_headerurl');

/**
 * Change the title attribute for the logo link on the login page
 */
function custom_login_headertitle($title) {
  return bloginfo('name');
}
add_filter('login_headertitle', 'custom_login_headertitle');
0

CSS Column Classes and Shortcodes

CSS:

/*
 * Uses column classes from GaryJ's variation of Brian Gardner's Genesis column classes
 * http://www.studiopress.com/support/showthread.php?t=50959
 */

.one-half,
.one-third,
.two-thirds,
.one-fourth,
.two-fourths,
.three-fourths,
.one-fifth,
.two-fifths,
.three-fifths,
.four-fifths,
.one-sixth,
.two-sixths,
.three-sixths,
.four-sixths,
.five-sixths {
    float: left;
    margin: 0 0 20px;
    padding-left: 3%;
}
.one-half,
.two-fourths,
.three-sixths {
    width: 48%;
}
.one-third,
.two-sixths {
    width: 31%;
}
.two-thirds,
.four-sixths {
    width: 65%;
}
.one-fourth {
    width: 22.5%;
}
.three-fourths {
    width: 73.5%;
}
.one-fifth {
    width: 17.4%;
}
.two-fifths {
    width: 37.8%;
}
.three-fifths {
    width: 58.2%;
}
.four-fifths {
    width: 78.6%;
}
.one-sixth {
    width: 14%;
}
.five-sixths {
    width: 82%;
}
.first {
    clear: both;
    padding-left: 0;
}
// Shortcodes are based on WooThemes column shortcodes
// Replace WP autop formatting
function myprefix_remove_wpautop($content) {
	$content = do_shortcode( shortcode_unautop( $content ) );
	$content = preg_replace('#^<\/p>|^<br \/>|<p>$#', '', $content);
	return $content;
}

// Column Shortcodes

function myprefix_one_half_first($atts, $content = null) {
   return '<div class="one-half first">' . myprefix_remove_wpautop($content) . '</div>';
}
add_shortcode('one-half-first', 'myprefix_one_half_first');

function myprefix_one_half($atts, $content = null) {
   return '<div class="one-half">' . myprefix_remove_wpautop($content) . '</div>';
}
add_shortcode('one-half', 'myprefix_one_half');

function myprefix_two_thirds_first($atts, $content = null) {
   return '<div class="two-thirds first">' . myprefix_remove_wpautop($content) . '</div>';
}
add_shortcode('two-thirds-first', 'myprefix_two_thirds_first');

function myprefix_one_third_first($atts, $content = null) {
   return '<div class="one-third first">' . myprefix_remove_wpautop($content) . '</div>';
}
add_shortcode('one-third-first', 'myprefix_one_third_first');

function myprefix_one_third($atts, $content = null) {
   return '<div class="one-third">' . myprefix_remove_wpautop($content) . '</div>';
}
add_shortcode('one-third', 'myprefix_one_third');

/* etc. */

Example HTML:

<!-- HTML -->
<p class="one-half first">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.</p>

<p class="one-half">Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.</p>

Shortcode Example:

[one-half-first]Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.[/one-half-first] [one-half]Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.[/one-half]

Output:

Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.

Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.

0

Genesis: Custom search button and search form text

// Search form text
add_filter('genesis_search_text', 'custom_search_text');
function custom_search_text($text) {
    return esc_attr('Search...');
}

// Add custom text for search button
add_filter('genesis_search_button_text', 'custom_search_button_text');
function custom_search_button_text($text) {
    return esc_attr('Go');
}
2

Genesis Footer Content

Customize the footer text

add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
    $creds = '&copy;' . date('Y') . ' '
		. get_bloginfo('name') .
		'. All rights reserved. Powered by <a href="http://wordpress.org/">WordPress</a>.';
    echo $creds;
}

Remove Footer Content

This will remove the footer credits text and ‘back to top’ link.

add_filter('genesis_footer_output', 'footer_output_filter', 10, 1);
function footer_output_filter($footer_content) {
    $footer_content = '';
    return $footer_content;
}

Replace Footer With A WordPress Custom Menu

This will replace the default footer with credit text and a WordPress custom navigation menu.
Ex. © Copyright 2011 LBnuke. All rights reserved.    Home | About | Archives | Contact

remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'child_do_footer' );
function child_do_footer() {
	$creds = '&copy; Copyright '. date('Y') . ' ' . get_bloginfo('name') . ' . All rights reserved.';
	$footernav = wp_nav_menu( array('menu' => 'footer' ));
	echo $footernav;
	?>
	<p class="creds"><?php echo $creds; ?></p>
<?php }
0

Genesis: Custom superfish arguments

// functions.php
function custom_superfish_menu() {
    if ( genesis_get_option('nav_superfish') ) {
			wp_deregister_script('superfish-args');
			wp_enqueue_script('superfish-args', CHILD_URL.'/superfish.args.js', array('jquery'), '1.0', TRUE);
    }
}
add_action('get_header', 'custom_superfish_menu');
// superfish.args.js
jQuery(document).ready(function($) { 

	$('#nav ul.superfish, #subnav ul.superfish, #header ul.nav, #header ul.menu').superfish({
		delay:       0,		// delay on mouseout
		speed:       'fast',
		animation:   {opacity:'show',height:'show'},	// fade-in and slide-down animation
		autoArrows:    false,
		dropShadows: false,		// disable drop shadows
		pathClass:	'current-menu-item',
		onInit:	function(){
			$(this).addClass('my-custom-class');
		}
	});

});
0

Genesis: Parent Page Templates

The template below displays child posts below any page content of the parent post with featured image thumbnails. Images are linked to child page. If there is an image before any page content on the child page, it will not display in order to avoid breaking the layout on posts with large images.

To display the images on the right side, change the class on this line (~ line 17):

genesis_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'alignleft post-image' ) ) );

from

'class' => 'alignleft post-image'

to

'class' => 'alignright post-image'

Parent Page Template:

<?php // Template Name: Parent-Image-Left

add_action('genesis_after_loop', 'bd_child_pages');
function bd_child_pages(){
		global $post;
?>

<div id="child-pages">

	<?php query_posts( 'post_type=page&post_parent='.$post->ID.'&orderby=menu_order&order=ASC' ); ?>
	<?php if( have_posts() ) : while ( have_posts() ) : the_post(); ?>

		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

<?php
	echo '<a href="' . get_permalink($post->ID) . '" >';
	    genesis_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'alignleft post-image' ) ) );
	echo '</a>';

	$content = apply_filters( 'the_content', get_the_content() );

	preg_match('#<p[^>]*>(.*)</p>#isU', $content, $matches);
	$content = preg_replace('/<img[^>]+\>/i', '', $matches[0]);

	echo $content;

	$count = post_word_count();
	if( sizeof( explode( " ", $content) ) < $count ) { ?>
	<div class="readmore">
		<a href="<?php the_permalink(); ?>">Read more &hellip;</a>
	</div>
	<?php	} ?>

<div class="clear"></div>
<?php endwhile; endif; ?>
</div><!--end child-pages-->

<?php }

genesis();

functions.php:

// Post word count
function post_word_count() {
    ob_start();
    the_content();
    $wcount= ob_get_clean();
    return sizeof(explode(" ", $wcount) );
    ob_end_clean();
}

Changelog
2/23/2011: Added links to featured images and ob_end_clean() to word count function.

0

genesis();

This is what happens when you call the genesis() function:

function genesis() {
	get_header();

	genesis_before_content_sidebar_wrap();
	?>
	<div id="content-sidebar-wrap">
		<?php genesis_before_content(); ?>
		<div id="content" class="hfeed">
			<?php
				genesis_before_loop();
				genesis_loop();
				genesis_after_loop();
			?>
		</div><!-- end #content -->
		<?php genesis_after_content(); ?>
	</div><!-- end #content-sidebar-wrap -->
	<?php
	genesis_after_content_sidebar_wrap();

	get_footer();
}