Skip to content

Instantly share code, notes, and snippets.

@amboutwe
amboutwe / yoast_seo_breadcrumb_add_woo_shop.php
Last active March 15, 2024 14:55
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@lukecav
lukecav / DNS Prefetch domains
Last active March 30, 2024 20:53
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@ControlledChaos
ControlledChaos / README.md
Created December 28, 2016 22:00
Merge an array of query variables with an existing WordPress query.

Merge Query Variables

WordPress Snippet

I was tasked with alphabetizing the archive of a custom post type using an off-the-shelf theme. The theme's archive.php file used the global variable global $wp_post to set the query.

The example here was placed in a custom post type archive (archive-example.php) following the global variable to merge with the default query. One can use this with any of the query variables.

@leahtard
leahtard / node.twig.html
Last active June 9, 2022 18:32
Get file url in node for Drupal 8 twig template
{# Get URL of single file field #}
{{ node.field_file.entity.uri.value }}
{# Get URL of multi file field #}
{{ node.field_file['#items'].entity.uri.value }}
{# Trun into link #}
{{ file_url(node.field_file.entity.uri.value) }}
{# Check if there is at least one value #}
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 26, 2024 10:15
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@isGabe
isGabe / get-highlight-terms.php
Last active February 12, 2022 16:22
WordPress: Output a list of taxonomy terms, then highlight the terms the belong to the current post. Updated to use in_array() to add a "current" CSS class to terms that the current post has. This way we don't have to worry about keeping up with terms in the CSS. Hooray for logic! #snippet #WordPress
<?php
/*
As the title implies, this will give you a way to
1. output a complete list of terms for a given taxonomy (nothing special there)
2. highlight the terms that the current post has (the magic!)
Probably need to figure out a better way to echo out the url of the term archive page...
*/