Skip to content

Instantly share code, notes, and snippets.

@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 #}
@corsonr
corsonr / functions.php
Created September 28, 2016 08:33
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@annalinneajohansson
annalinneajohansson / change_acf_color_picker.php
Created October 21, 2015 12:00
Adds client custom colors to WYSIWYG editor and ACF color picker. #wordpress
<?php
function change_acf_color_picker() {
$client_colors = array(
"#DD3333",
"#81D742",
"#1E73BE",
"#8224E3",
"#DD9933",
"#EEEE22"