Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
anonymous
anonymous / functions.php
Created July 25, 2014 12:32
Current Category Recent Posts
//* Recent Posts Widget Filtered by Current Category
add_filter( 'widget_posts_args', 'my_widget_posts_args');
function my_widget_posts_args($args) {
if ( is_category() ) { // Adds the category parameter in the query if we display a category
$cat = get_queried_object();
return array(
'posts_per_page' => 10, // The number of posts shown
'no_found_rows' => true,
'post_status' => 'publish',
'ignore_sticky_posts' => true,
@JiveDig
JiveDig / Remove titles from pages only
Last active December 17, 2015 05:09
Remove titles from pages only
// Remove titles from pages only
add_action('get_header', 'child_remove_page_titles');
function child_remove_page_titles() {
$pages=array();
if (is_page($pages)) {
remove_action('genesis_entry_header', 'genesis_do_post_title');
}
}
@JiveDig
JiveDig / post_count_per_page.php
Last active December 17, 2015 05:19
Set the number of posts per page (post count). Must be in functions.php
// Set the number of posts per page
add_filter( 'pre_get_posts', 'be_archive_query' );
// @link http://www.billerickson.net/customize-the-wordpress-query/
function be_archive_query( $query ) {
if( $query->is_main_query() && $query->is_archive() ) {
$query->set( 'posts_per_page', 12 );
}
}
// OR
@JiveDig
JiveDig / gist:5834083
Last active December 18, 2015 19:39
Use WP_Query To Alter The Posts Per Page Of A Custom Taxonomy Term Archive Of A Custom Post Type. When using Post Types Order plugin ( ) add: 'orderby' => 'menu_order', to the $args
<?php
//* Replace the standard loop with our custom loop
//* props to David Wang, he is the man!
// @author David Wang
// @link http://genesissnippets.com/genesis-custom-loop/
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'child_do_custom_loop' );
function child_do_custom_loop() {
@JiveDig
JiveDig / change_login_logo.php
Last active December 26, 2015 19:19
Change login logo and link. logo.png goes in /child_theme/images/ directory
/**
* Change login logo
* Max image width should be 320px
* @link http://andrew.hedges.name/experiments/aspect_ratio/
*/
add_action('login_head', 'rgt_custom_dashboard_logo');
function rgt_custom_dashboard_logo() {
echo '<style type="text/css">
.login h1 a {
background-image:url('.get_stylesheet_directory_uri().'/images/logo.png) !important;
@JiveDig
JiveDig / remove_post_content.php
Created October 29, 2013 02:34
Remove post content
//* Remove the post content (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
@JiveDig
JiveDig / link_featured_image_to_post.php
Created November 8, 2013 15:26
Link featured image (post thumbnail) to the post. Use the_title_attribute()
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('book-thumbnail', array('class' => 'book-thumbnail')); ?></a>
@JiveDig
JiveDig / register_new_widget_area.php
Created November 8, 2013 19:55
Register new Genesis widget area
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'after-post',
'name' => __( 'After Post', 'theme-name' ),
'description' => __( 'This is the widget that appears after a single posts.', 'theme-name' ),
) );
@JiveDig
JiveDig / display_widget_area.php
Last active December 27, 2015 19:19
Display a genesis widget area
<?php
if ( is_active_sidebar( 'after-entry' ) ) {
genesis_widget_area( 'after-entry', array(
'before' => '<div class="after-entry">',
'after' => '</div>',
) );
}
@JiveDig
JiveDig / featured_image_on_single_post.php
Created December 4, 2013 21:45
Show featured image (post thumbnail) on single posts
<?php
// Show featured image on single posts
add_action( 'genesis_before_entry_content', 'child_featured_post_image', 8 );
function child_featured_post_image() {
if ( ! is_singular( 'post' ) ) return;
the_post_thumbnail('post-image');
}