Skip to content

Instantly share code, notes, and snippets.

View lepittenger's full-sized avatar

Lauren Levin (Pittenger) lepittenger

View GitHub Profile
@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 / 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 / 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 / index.php
Created June 3, 2015 14:42
Check if the_content is empty
<?php
if ( $post->post_content=="" ) {
// do something for posts without content
} else {
// do something for posts with content
};
// OR
@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 / addmenuatts.php
Created April 14, 2015 20:47
Add attributes to WordPress menu items
function add_menu_atts( $atts, $item, $args ) {
$atts['itemprop'] = 'url';
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_atts', 10, 3 );
@lepittenger
lepittenger / genesis-video-before-content.php
Last active September 22, 2017 19:11
Take a link from a video and embed it before the post content with Genesis
<?php
/**
* Add video from a custom field before the post content on single posts.
*/
add_action( 'genesis_entry_content','lp_video_before_entry_content_on_singles', 5 );
function lp_video_before_entry_content_on_singles() {
if ( is_singular() ) {
@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';