Skip to content

Instantly share code, notes, and snippets.

View MaruscaGabriel's full-sized avatar

Marusca Gabriel MaruscaGabriel

View GitHub Profile
<?php
/**
* Default Term Description
*
*/
function mg_default_term_description( $desc, $term ) {
if( ( is_category() || is_tag() || is_tax() ) && empty( $desc ) )
$desc = $term->description;
@MaruscaGabriel
MaruscaGabriel / functions.php
Created January 26, 2015 16:26
Automatically display titles on category, tag and taxonomy archives
<?php
/**
* Default Category Title in Genesis
*
* @author Marusca Gabriel
*/
function mg_default_category_title( $headline, $term ) {
if( ( is_category() || is_tag() || is_tax() ) && empty( $headline ) )
$headline = $term->name;
@MaruscaGabriel
MaruscaGabriel / Hooks
Last active August 29, 2015 14:14
Genesis Post hooks 2.0 and Legacy
<?php
// HTML5 Hooks
add_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 );
add_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
add_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
add_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
add_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_content', 'genesis_do_post_content' );
@MaruscaGabriel
MaruscaGabriel / functions.php
Created January 26, 2015 19:12
Relocate titles under Header on page, post and other single pages
<?php
add_action( 'genesis_after_header','relocate_entry_title_singular' );
function relocate_entry_title_singular() {
if ( ! is_singular() )
return;
echo '<div class="entry-header-wrapper"><div class="wrap">';
genesis_do_post_title();
echo '</div></div>';
@MaruscaGabriel
MaruscaGabriel / functions.php
Created February 2, 2015 11:45
Reposition the secondary navigation menu above footer widget in Genesis
<?php
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_footer', 'genesis_do_subnav', 5 );
@MaruscaGabriel
MaruscaGabriel / schema-org-functions.php
Last active August 29, 2015 14:14
Genesis code for schema.org
<?php
// Remove the schema markup from an element
function mg_schema_empty( $attr ) {
$attr['itemtype'] = '';
$attr['itemprop'] = '';
$attr['itemscope'] = '';
return $attr;
}
@MaruscaGabriel
MaruscaGabriel / site-plugin.php
Created February 20, 2015 17:57
How to Create a Site-Specific WordPress Plugin (this file goes in /wp-content/plugins/yoursitename-plugin/)
<?php
/*
Plugin Name: Site Plugin for site.com
Description: Site specific code changes for site.com
*/
/* Start Adding Functions Below this Line */
/* Stop Adding Functions Below this Line */
?>
@MaruscaGabriel
MaruscaGabriel / home.php
Last active August 29, 2015 14:16
Remove pagination in Genesis pages
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' );
@MaruscaGabriel
MaruscaGabriel / functions.php
Created March 9, 2015 18:19
Remove Schema.org markup wraping Genesis
add_filter( 'genesis_attr_entry', 'prefix_attributes_entry_content', 15 );
function prefix_attributes_entry_content( $attributes ) {
unset( $attributes['class'] );
unset( $attributes['itemprop'] );
unset( $attributes['itemtype'] );
unset( $attributes['itemscope'] );
//* Blog posts microdata
if ( 'post' === get_post_type() ) {
$attributes['class'] = join( ' ', get_post_class() );
@MaruscaGabriel
MaruscaGabriel / functions.php
Created March 10, 2015 20:00
Customize tag cloud widget
/* Customize tag cloud widget*/
function my_tag_text_callback( $count ) {
return sprintf( _n('%s Articles', '%s Articles', $count), number_format_i18n( $count ) );
}
add_filter('widget_tag_cloud_args','set_number_tags');
function set_number_tags($args) {
$args = array('smallest' => 11, 'largest' => 11, 'number' => 30, 'orderby' => 'count','order' => 'DESC', 'topic_count_text_callback' => 'my_tag_text_callback' );
return $args;
}