This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// first, get the image ID returned by ACF | |
$image_id = get_field('my_image_field'); | |
// and the image size you want to return | |
$image_size = 'thumbnail'; | |
// use wp_get_attachment_image_src to return an array containing the image | |
// we'll pass in the $image_id in the first parameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// first, get the image object returned by ACF | |
$image_object = get_field('my_image_field'); | |
// and the image size you want to return | |
$image_size = 'thumbnail'; | |
// now, we'll exctract the image URL from $image_object | |
$image_url = $image_object['sizes'][$image_size]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// check to see if there is a post type in the URL | |
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ) { | |
// save it for later | |
$post_type = $_GET['post_type']; | |
// check to see if a search template exists | |
if ( locate_template( 'search-' . $post_type . '.php' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function merge_wp_query_args(...$sets) | |
{ | |
$meta_query = []; | |
$tax_query = []; | |
foreach ($sets as &$set) { | |
if (array_key_exists('meta_query', $set)) { | |
$meta_query[] = $set['meta_query']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_nav_wrap() { | |
// default value of 'items_wrap' is <ul id="%1$s" class="%2$s">%3$s</ul>' | |
// open the <ul>, set 'menu_class' and 'menu_id' values | |
$wrap = '<ul id="%1$s" class="%2$s">'; | |
// get nav items as configured in /wp-admin/ | |
$wrap .= '%3$s'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<header class="page-row"> | |
<h1>Site Title</h1> | |
</header> | |
<main class="page-row page-row-expanded"> | |
<p>Page content goes here.</p> | |
</main> | |
<footer class="page-row"> | |
<p>Copyright, blah blah blah.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
public $ID; | |
public $_user; | |
public $attributes = [ | |
'description', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
repos=("repo-name" "another-repo") | |
for repo in ${repos[@]}; do | |
echo | |
echo "* Processing $repo..." | |
echo | |
git clone --bare git@bitbucket.org:ORG/$repo.git | |
cd $repo.git | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function youtube_id_from_url( $url = null ) { | |
if ( ! $url || ( stripos( $url, 'youtube.com' ) === false && stripos( $url, 'youtu.be' ) === false ) ) { | |
return false; | |
} | |
$parsed_url = parse_url( $url ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_nav_wrap() { | |
// checks if there is an item in the cart | |
// returns default items + cart link if there is | |
// returns default items if the cart is empty | |
if (sizeof(WC()->cart->get_cart()) != 0) { | |
$wrap = '<ul id="%1$s" class="%2$s">'; |
NewerOlder