Skip to content

Instantly share code, notes, and snippets.

View rianrietveld's full-sized avatar
🌷

Rian Rietveld rianrietveld

🌷
View GitHub Profile
@rianrietveld
rianrietveld / rwd_has_post_youtube(
Created August 14, 2014 12:20
Embed a YouTube in WordPress, using Advances Custom fields
<?php
function rrwd_has_post_youtube( $post_id ) {
if ( !function_exists( 'get_field') )
return;
if ( get_field( 'acf_youtube', $post_id ) ) {
echo '<iframe class="frame-youtube" src="http://www.youtube.com/embed/'. get_field( 'acf_youtube') . '?feature=oembed" name="youtube" frameborder="0" allowfullscreen></iframe>' . "\n";
@rianrietveld
rianrietveld / acf-date.php
Created January 28, 2015 07:53
ACF display date in custom format
<?php
$meta_value = get_post_meta( get_the_ID() , 'acf_date', true );
$date = date_i18n( 'd M Y' , strtotime( $meta_value ) );
?>
@rianrietveld
rianrietveld / get_menu_name.php
Created January 31, 2015 08:24
Function for grabbing a WP nav menu theme location name
<?php
/**
* Function for grabbing a WP nav menu theme location name.
*
* @since 2.0.0
* @access public
* @param string $location
* @return string
*/
function gameaccess_get_menu_name( $location ) {
@rianrietveld
rianrietveld / format-acf-date.php
Created January 31, 2015 08:26
Format ACF date for display
<?php
function gameaccess_acf_date( $id, $field ) {
$meta_value = get_post_meta( $id , $field, true );
echo date_i18n( 'F d, Y' , strtotime( $meta_value ) );
}
?>
@rianrietveld
rianrietveld / responsive-menu-old.js
Created April 22, 2015 15:15
Inaccessible Genesis responsive-menu.js
jQuery(function( $ ){
$("header .genesis-nav-menu, .nav-primary .genesis-nav-menu").addClass("responsive-menu").before('<div class="responsive-menu-icon"></div>');
$(".responsive-menu-icon").click(function(){
$(this).next("header .genesis-nav-menu, .nav-primary .genesis-nav-menu").slideToggle();
});
$(window).resize(function(){
if(window.innerWidth > 768) {
@rianrietveld
rianrietveld / responsive-menu.js
Created April 22, 2015 15:16
Accessible Genesis responsive-menu.js
jQuery(function( $ ){
$("header .genesis-nav-menu, .nav-primary .genesis-nav-menu").addClass("responsive-menu").before('<h2 class="screen-reader-text" id="rian-main-nav">Main navigation</h2><button class="responsive-menu-icon" aria-expanded="false">Menu</button>');
$(".responsive-menu-icon").click(function(){
var _this = $( this );
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
$(this).next("header .genesis-nav-menu, .nav-primary .genesis-nav-menu").slideToggle();
});
@rianrietveld
rianrietveld / english.php
Last active August 29, 2015 14:23
Template file language switcher on entry-content only (Genesis)
<?php
/**
* Template Name: English page
* Adds lang=en to the entry-content div only
*
* @package Genesis\Templates
* @author Rian Rietveld
* @license GPL-2.0+
*/
@rianrietveld
rianrietveld / cpt-template.php
Last active August 29, 2015 14:23
Assign a template to a single custom post type page
<?php
// set custom post type templates in post meta
add_action('publish_name_cpt', 'prefix_add_template', 10, 2 );
function prefix_add_template( $post_id, $post ) {
if ( $post_id == 1234 ) {
add_post_meta( $post_id, '_wp_page_template', 'your-template.php', true );
}
@rianrietveld
rianrietveld / remove-items-admin-bar.php
Created June 14, 2015 07:58
Remove items from the WordPress admin bar
<?php
add_action( 'admin_bar_menu', 'prefix_remove_stuf_admin_bar', 999 );
function prefix_remove_stuf_admin_bar( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'wp-logo' );
$wp_admin_bar->remove_node( 'comments' );
$wp_admin_bar->remove_node( 'wpseo-menu' );
if ( !current_user_can( 'edit_others_pages' ) ) {
@rianrietveld
rianrietveld / functions.php
Last active August 29, 2015 14:25
Add Accessibility theme support to Genesis
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add Accessibility support
add_theme_support( 'genesis-accessibility', array( 'headings', 'drop-down-menu', 'search-form', 'skip-links', 'rems' ) );