Skip to content

Instantly share code, notes, and snippets.

View anythinggraphic's full-sized avatar
☺️
Be the reason someone smiles today.

Kevin Donnigan anythinggraphic

☺️
Be the reason someone smiles today.
View GitHub Profile
<?php
/* @link https://anythinggraphic.net/yoast-seo-add-custom-social-share-images-for-archive-category-pages-in-wordpress
/* Add custom Twitter Social Share images for Yoast SEO for Archive pages
----------------------------------------------------------------------------------------*/
add_filter( 'wpseo_twitter_image', 'ag_yoast_seo_tw_share_images', 10, 1 );
function ag_yoast_seo_tw_share_images( $img ) {
if( is_post_type_archive( 'archivename') ) {
$img = get_stylesheet_directory_uri().'/images/your-image-file.jpg';
}
if( is_category( 'categoryname') ) {{
@anythinggraphic
anythinggraphic / structural-wraps.php
Last active May 8, 2019 16:13
Genesis: Add structural wraps to entry-header
<?php
add_action( 'genesis_entry_header', 'ag_header_wrap_open', 5 );
function ag_header_wrap_open() {
echo '<div class="wrap align-center">';
}
add_action( 'genesis_entry_header', 'ag_header_wrap_close', 14 );
function ag_header_wrap_close() {
echo '</div>';
@anythinggraphic
anythinggraphic / functions.php
Last active May 8, 2019 16:13
Change the header logo link in Genesis (Updated for new themes that support HTML5 and schema rich snippets)
<?php
/* @link https://anythinggraphic.net/change-header-logo-link-in-genesis-updated-for-html5-schema/
/* Updated from Bill Erickson's original post http://www.billerickson.net/code/genesis-change-logo-url to include support for new HTML5 themes and schema rich snippets.
/* Change header logo link in Genesis
----------------------------------------------------------------------------------------*/
add_filter('genesis_seo_title', 'ag_change_logo_url', 10, 3 );
function ag_change_logo_url( $title, $inside, $wrap ) {
$inside = sprintf( '<a href="%s" title="%s">%s</a>', esc_url( 'http://nmbree.org' ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
$title = sprintf( '<%s class="site-title" itemscope="headline">%s</%s>', $wrap, $inside, $wrap );
@anythinggraphic
anythinggraphic / functions.php
Last active May 8, 2019 16:13
Change microdata for Article with the class 'entry' in Genesis child themes
<?php
/* @link https://anythinggraphic.net/change-class-id-itemtype-and-other-attributes-in-genesis/
/* Change microdata for Article with the class 'entry' in Genesis child themes
----------------------------------------------------------------------------------------*/
add_filter( 'genesis_attr_entry', 'ag_article_attributes', 20 );
function ag_article_attributes( $attributes ) {
if( is_singular( 'leadership' ) ) {
// class, id, itemscope, itemtype, etc.
$attributes['itemtype'] = 'http://schema.org/Organization';
@anythinggraphic
anythinggraphic / functions.php
Last active May 8, 2019 16:13
Change the itemprop schema microdata attribute for navigation menu items
<?php
/* @link https://anythinggraphic.net/change-navigation-menu-item-url-itemtype-schema-microdata/
/* Change microdata for specific menu items
----------------------------------------------------------------------------------------*/
add_filter( 'nav_menu_link_attributes', 'ag_menu_item_attributes', 10, 3 );
function ag_menu_item_attributes( $atts, $item, $args ) {
// The ID of the target menu item
// Remove this to target all menu items
$menu_target = 123;
@anythinggraphic
anythinggraphic / functions.php
Last active May 8, 2019 16:13
Override Header Image (Appearance > Customize) with an retina version
<?php
/* @link https://anythinggraphic.net/header-image-logo-in-genesis-and-wordpress-with-a-retina-2x-version/
/* Override Header Image (Appearance > Customize) with an @2x version
----------------------------------------------------------------------------------------*/
add_theme_support( 'custom-header', array(
'header_image' => '',
'header-selector' => '.site-title a',
'header-text' => false,
'height' => 188,
@anythinggraphic
anythinggraphic / functions.php
Last active May 8, 2019 16:13
Move Post Title and Post Info from Entry Header to Entry Content
<?php
/* Move Post Title and Post Info from inside Entry Header to Entry Content on Posts page
----------------------------------------------------------------------------------------*/
add_action( 'genesis_before_entry', 'reposition_entry_header' );
function reposition_entry_header() {
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
@anythinggraphic
anythinggraphic / functions.php
Last active March 13, 2018 17:52
Gravity Forms: Change Stripe receipt description.
/* Change the description of Gravity Forms/Stripe Form Stripe Receipt (product)
----------------------------------------------------------------------------------------*/
add_filter( 'gform_stripe_charge_description', 'ag_custom_product_receipt', 10, 4 );
function ag_custom_product_receipt( $description, $strings, $entry, $submission_data ) {
$payment_amount = rgar( $submission_data, 'payment_amount' );
$description = "Payment Amount: " . $payment_amount;
GFCommon::log_debug( __METHOD__ . "(): Custom description for the product: " . $description );
@anythinggraphic
anythinggraphic / loop.php
Last active October 18, 2017 13:55
Within your custom loop, get all taxonmies for a custom post type (CPT) and display each post within those taxonomies.
<?php
/* @link TBA
/* Within your custom loop, get all taxonomies for a custom post type (CPT) and display each post within those taxonomies
----------------------------------------------------------------------------------------*/
$post_type = 'your_cpt_name';
// Get all of the taxonomies for this post type
$taxonomies = get_object_taxonomies((object) array( 'post_type' => $post_type )); ?>
/*
Original link http://www.templatemonster.com/blog/style-radioes-radio-buttons-css adapted to Gravity Forms.
Uses Font Awesome. Make sure to wrap labels in <span> like so:
<script type="text/javascript">
jQuery(function($) {
$(".gfield_checkbox label, .gfield_radio label").wrapInner("<span></span>")
});
</script>
*/