Skip to content

Instantly share code, notes, and snippets.

@robincornett
robincornett / functions.php
Created October 31, 2017 15:16
Code to remove landing pages from site search results. Assumes that templates are in the templates directory inside the theme.
<?php
add_action( 'pre_get_posts', 'leaven_search_hide_landing_page' );
/**
* Remove landing pages from the search results.
*
* @param $query \WP_Query
*
* @return mixed
*/
@robincornett
robincornett / woocommerce-output.php
Created October 16, 2017 17:23
Remove the WooCommerce lightbox and replace it with WP Featherlight. Note that this code also removes the main/featured image from the lightbox rotation.
<?php
add_action( 'wp_loaded', 'leaven_maybe_add_product_lightbox' );
/**
* Use the Woo lightbox if WP Featherlight isn't active.
*/
function leaven_maybe_add_product_lightbox() {
if ( function_exists( 'wp_featherlight' ) ) {
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
add_action( 'woocommerce_product_thumbnails', 'leaven_do_woocommerce_thumbnails', 20 );
@robincornett
robincornett / functions.php
Created October 2, 2017 14:43
Add the WooCommerce account menu endpoints to the SuperSide Me menu panel.
<?php
// Do not include the opening tag.
add_filter( 'supersideme_menu_output', 'prefix_add_woo_account_menu_supersideme' );
/**
* Mimic the WooCommerce account menu and add it to the SuperSide Me menu panel.
*
* @param $output_menu
*
@robincornett
robincornett / functions.php
Last active March 4, 2016 13:55
Create a helper function to get new Genesis term meta, but still backwards compatible.
<?php
// Do not include the opening tag.
/**
* Get the term meta (generally headline or intro text). Backwards compatible,
* but uses new term meta (as of Genesis 2.2.7)
* @param $term object the term
* @param $key string meta key to retrieve
* @param string $value string output of the term meta
@robincornett
robincornett / functions.php
Last active April 29, 2019 14:59
Modify the "no content matched your criteria" message in Genesis
<?php
// do not include the opening tag
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_one', 10, 2 );
function leaven_change_search_text_one( $text ) {
$text .= __( ' Would you like to try again?', 'leaven' );
$text .= get_search_form( false );
return $text;
@robincornett
robincornett / edd-options.php
Last active October 17, 2015 15:28
Modify image/output options for Genesis archives, both globally and at a more specific level
<?php
// Do not include the opening tag!
add_filter( 'genesis_options', 'leaven_downloads_archive_options' );
/**
* Change number of posts, as well as size and image alignment of featured image
* on EDD custom post type
*/
function leaven_downloads_archive_options( $args ) {
@robincornett
robincornett / functions-01.php
Last active November 27, 2017 08:25
Responsive menus for HTML5 Genesis themes. with updating skip links. The skip links must follow the pattern established in Genesis core.
<?php
//do not include the opening tag!
// Required Scripts and Styles
add_action( 'wp_enqueue_scripts', 'leaven_load_scripts', 15 );
function leaven_load_scripts() {
// Responsive Navigation
wp_enqueue_style( 'fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', array(), '4.3.0' );
@robincornett
robincornett / functions-alt.php
Last active November 8, 2016 23:32
Make Simple Social Icons a little more awesome with FontAwesome.
<?php
// do NOT include the opening tag
add_filter( 'simple_social_default_glyphs', 'rgc_simple_social_icons_glyphs' );
function rgc_simple_social_icons_glyphs( $glyphs ) {
$glyphs = array(
'bloglovin' => '<span class="fa fa-heart"></span><span class="screen-reader-text">Bloglovin</span>',
'dribbble' => '<span class="fa fa-dribbble"></span><span class="screen-reader-text">Dribbble</span>',
'email' => '<span class="fa fa-envelope"></span><span class="screen-reader-text">Email</span>',
@robincornett
robincornett / functions.php
Created February 16, 2015 14:07
snippet to use the term featured image as the post featured image on blog/archive pages, if the post has no featured image of its own. Requires the Display Featured Image for Genesis plugin.
<?php
// do not include the opening tag!
add_action( 'genesis_entry_content', 'rgc_add_term_image_archives' );
function rgc_add_term_image_archives() {
if ( ! is_home() && ! is_archive() ) {
return;
}
@robincornett
robincornett / photon.php
Last active February 21, 2022 17:12
Disable the Jetpack Photon module so that you can work with WordPress' image functions
<?php
// do not include the opening php tag
// turn Photon off so we can get the correct image
$photon_removed = '';
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) { // check that we are, in fact, using Photon in the first place
$photon_removed = remove_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ) );
}