Skip to content

Instantly share code, notes, and snippets.

@mvital
mvital / excerpt-as-instant-article-subtitle.php
Created January 11, 2017 15:42 — forked from webdados/excerpt-as-instant-article-subtitle.php
Use WordPress post excerpt as Facebook Instant Article subtitle
<?php
/* Instant Articles (https://wordpress.org/plugins/fb-instant-articles/) - Use post excerpt as subtitle */
add_filter( 'instant_articles_subtitle', 'hf_instant_articles_subtitle' );
function hf_instant_articles_subtitle( $subtitle ) {
$excerpt = get_the_excerpt();
if ( trim($excerpt)!='' ) $subtitle = trim($excerpt);
return $subtitle;
}
@mvital
mvital / functions.php
Created January 11, 2017 12:28 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@mvital
mvital / ACF If Else field.php
Created January 11, 2017 12:26 — forked from jpcontrerasv/ACF If Else field.php
ACF If Else field
<?php if ( get_field( 'field_name' ) ): ?>
This is displayed when the field_name is TRUE or has a value.
<?php else: // field_name returned false ?>
This is displayed when the field is FALSE, NULL or the field does not exist.
<?php endif; // end of if field_name logic ?>
@mvital
mvital / acf-link-picker-shortcode.php
Created January 11, 2017 12:24 — forked from khromov/acf-link-picker-shortcode.php
ACF Link Picker Shortcode
@mvital
mvital / custom-search-acf-wordpress.php
Created January 9, 2017 15:54 — forked from jserrao/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. I updated this original script with better documentation and XSS / SQL injection support.
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
I also updated this work to include XSS and SQL injection projection
[list_searcheable_acf list all the custom fields we want to include in our search query]
@return [array] [list of custom fields]
@mvital
mvital / functions.php
Created November 25, 2016 10:56 — forked from gnistdesign/functions.php
Custom tax query
<?php
add_rewrite_rule(
'^result/([^/]*)/?([^/]*)$',
'index.php?pagename=result&style_slug=$matches[1]&gender_slug=$matches[2]',
'top' );
add_rewrite_tag('%style_slug%','([^/]*)');
add_rewrite_tag('%gender_slug%','([^/]*)');