Skip to content

Instantly share code, notes, and snippets.

View chaiperez's full-sized avatar
🏠
Working from home

Chai chaiperez

🏠
Working from home
View GitHub Profile
@cdils
cdils / archive-testimonials.php
Last active April 17, 2023 20:13
This is code for a custom page template removing the standard Genesis loop and inserting a custom loop. Similar to https://gist.github.com/4684423.js, but without a grid loop.
<?php
/**
* Template Name: Testimonial Archives
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 4, 2014 15:32
Genesis: Replace Genesis primary menu with a dynamically updated category menu. Uses a custom walker class.
//* Unregister primary/secondary navigation menus
remove_theme_support( 'genesis-menus' );
//* Add New Menu Navigation with dynamic child category walker class
add_action( 'genesis_after_header', 'webendev_subcat_navigation', 15 );
function webendev_subcat_navigation() {
echo '<nav class="nav-primary">';
wp_nav_menu(
array(
'container_class' => 'wrap',
@thomasgriffin
thomasgriffin / gist:8815376
Created February 5, 2014 00:43
Disables lightbox functionality for a specific gallery ID.
<?php
add_filter( 'envira_gallery_pre_data', 'tgm_envira_disable_lightbox', 10, 2 );
function tgm_envira_disable_lightbox( $data, $gallery_id ) {
// You can target this by specific ID if you want. If you want this for all galleries, just remove this line. Change 324 to your gallery ID.
if ( 324 !== $gallery_id ) {
return $data;
}
// Empty the link field for each image.
@thomasgriffin
thomasgriffin / gist:018eb3183e83d265c4ee
Created June 10, 2014 16:03
Use Soliloquy image as a background slide instead of regular image.
<?php
add_filter( 'soliloquy_output_item_style', 'add_soliloquy_bg_image', 10, 4 );
function add_soliloquy_bg_image( $style, $id, $image, $idata ) {
$style = 'background-image:url(' . $image['src'] . ');';
return $style;
}
add_filter( 'soliloquy_output_image_slide', 'remove_soliloquy_slide_image' );
function remove_soliloquy_slide_image( $imagehtml ) {
$imagehtml = '';
@neilgee
neilgee / front-page.php
Last active September 15, 2016 06:11
Genesis Custom Front Page - No Inner Content
<?php
//do not add in opening php tag
/**
* Remove Inner Home Page Content on a Genesis Theme
*
* @package Genesis Custom Front Page - No Inner Content
* @author Neil Gee
* @link https://wpbeaches.com/remove-inner-html-mark-content-genesis-home-page/
* @copyright (c)2014, Neil Gee
@calliaweb
calliaweb / display-advanced-custom-fields-gallery-as-an-envira-gallery.php
Last active November 11, 2020 18:44
Display Advanced Custom Fields Gallery as an Envira Gallery
@ridinghoodmedia
ridinghoodmedia / functions.php
Last active July 5, 2020 21:03
Populate Envira Gallery with ACF gallery field
/*
* Populate Envira Gallery with ACF gallery field
*
* Filters the gallery $data and replaces with the image data for our images in the ACF gallery field.
*
* @uses ACF Pro
* @uses Envira Gallery
* @param $data
* @param $gallery_id
*/
@verticalgrain
verticalgrain / srcset.php
Created December 20, 2016 18:46
Wordpress srcset snippet for ACF image field
<?php
// Use an ACF image field
// Set the 'return value' option to "array" (this is the default)
// This example uses three image sizes, called medium, medium_large, thumbnail
$imageobject = get_field('image');
if( !empty($imageobject) ):
echo '<img alt="' . $imageobject['title'] . '" src="' . $imageobject['sizes']['medium'] . '" srcset="' . $imageobject['sizes']['medium_large'] .' '. $imageobject['sizes']['medium_large-width'] .'w, '. $imageobject['sizes']['medium'] .' '. $imageobject['sizes']['medium-width'] .'w, '. $imageobject['sizes']['thumbnail'] .' '. $imageobject['sizes']['thumbnail-width'] .'w">';
endif;
?>
@C1tas
C1tas / transition_mixin
Created June 6, 2017 06:55
SASS:Transition Mixin
@mixin transition($transition-property, $transition-time, $method) {
-webkit-transition: $transition-property $transition-time $method;
-moz-transition: $transition-property $transition-time $method;
-ms-transition: $transition-property $transition-time $method;
-o-transition: $transition-property $transition-time $method;
transition: $transition-property $transition-time $method;
}
/* Usage - Stick into the top of your SCSS sheet and @include where needed for cross browser transitions.
.class {
@megclaypool
megclaypool / ACF Responsive Background Image.md
Last active June 12, 2024 03:17
Responsive Images (with srcset and sizes) in WordPress (PHP) This is for use in a php template, taking advantage of built-in WP image functions to generate a fancy responsive image tag, complete with srcset and sizes. Set a variable equal to the res

This is Jason's Responsive Background Image Twig Macro translated into PHP for use with ACF image fields:

<?php function responsive_ACF_background_image($image, $display_style, $css_path) {
  $retina_style = $display_style . "2x";
  echo "<style>
      $css_path {
          background-image: url(\"" . $image[sizes][$display_style] . "\");
      }
 @media