Skip to content

Instantly share code, notes, and snippets.

View lepittenger's full-sized avatar

Lauren Levin (Pittenger) lepittenger

View GitHub Profile
@lepittenger
lepittenger / .htaccess
Created December 3, 2024 17:04
Load images locally from remote
# Redirect WordPress local development uploads, to dev/prod server.
RedirectMatch 301 ^/wp-content/uploads/(.*) https://mywebsite.wpenginepowered.com/wp-content/uploads/$1
@lepittenger
lepittenger / Styles Hierarchy
Created December 3, 2024 17:02
Block Theme Styles Hierarchy
1 Base/Default Styles - root of theme.json styles section
2 Element styles - default styles for elements such as links and buttons (styles.elements)
3 Block styles - default styles for blocks (styles.blocks)
4 Block Type Style Variations - variations of blocks styled the same accross different pages such as border button
5 Section Style - when you want part of a page to look different
6 Template styles
@lepittenger
lepittenger / bash.sh
Last active August 18, 2023 16:13
Linting PHP files
$ vendor/bin/phpcbf {filename}
$ vendor/bin/phpcs {filename}
@lepittenger
lepittenger / get-link-by-page-template-name.php
Last active August 18, 2023 16:02
Get link by page template name
@lepittenger
lepittenger / .htaccess
Created August 18, 2023 15:52
Load remote images locally
# Redirect WordPress uploads requests, to dev/prod server
RedirectMatch 301 ^/wp-content/uploads/(.*) https://mywebsite.com/wp-content/uploads/$1
@lepittenger
lepittenger / test-gutenberg-blocks.html
Created January 27, 2023 21:52
Test Gutenberg Blocks Content
<!-- wp:group {"backgroundColor":"vivid-red","textColor":"white","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-white-color has-vivid-red-background-color has-text-color has-background"><!-- wp:paragraph -->
<p><strong>Each block type is on a separate page.</strong> </p>
<!-- /wp:paragraph -->
<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size">Use the links at the bottom of this page to navigate between pages.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
@lepittenger
lepittenger / Conditional orderby
Created December 29, 2021 16:47
Conditional Orderby
$order = '';
if ( sort_group = 1 ) {
$order = 'ASC';
}
if ( sort_group = 1 ) {
$order = 'DESC';
}
@lepittenger
lepittenger / page-cpts-grouped-by-taxonomy.php
Created July 31, 2017 02:14
Loop Through CPTs + Group by Custom Taxonomy Terms
<?php
/**
*
* Loop through some custom post types and group them by taxonomy term,
* outputting the taxonomy term names before the set of posts
*
*/
// get all of the custom taxonomy terms
$taxonomy = 'my_custom_taxonomy';
@lepittenger
lepittenger / youtube-thumbnail.php
Last active July 28, 2017 21:49
Display a YouTube Thumbnail
<?php
/**
*
* Display a YouTube video thumbnail based on a URL in a template
*
*/
$video_link = 'https://www.youtube.com/watch?v=B9duuy7lr08';
@lepittenger
lepittenger / page_blog.php
Created June 13, 2016 16:17
Genesis blog template with page content before posts
<?php
//* Template Name: Blog
//* Remove the blog heading which caused duplicate page title with the below standard loop
remove_action( 'genesis_before_loop', 'genesis_do_blog_template_heading' );
//* Show page content above posts
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );
genesis();