Skip to content

Instantly share code, notes, and snippets.

View rianrietveld's full-sized avatar
🌷

Rian Rietveld rianrietveld

🌷
View GitHub Profile
@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 / 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 / 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 / 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 / rrwd_remove_page_template
Created April 24, 2014 07:52
Remove page templates from dropdown page attributes in WordPress ( >= 3.9 )
<?php
add_filter( 'theme_page_templates', 'rrwd_remove_page_template' );
function rrwd_remove_page_template( $pages_templates ) {
unset( $pages_templates['page_blog.php'] );
unset( $pages_templates['page_archive.php'] );
return $pages_templates;
}
?>
@rianrietveld
rianrietveld / gist:10629873
Created April 14, 2014 09:01
Changing a non-background image on hover with CSS
<a href="https://twitter.com/RianRietveld"><img src="[email protected]" alt="Follow me on Twitter"></a>
@rianrietveld
rianrietveld / rrwd-genesis-acf-silder-output.php
Created February 13, 2014 09:58
Custom Output for Genesis Responsive slider combined with Advanaced Custom Fields
<?php
/**
* Home Slider
*
* Uses the Genesis Responsive slider combined with Advanaced Custom Fields
* setting in Dashboard - Instellingen website
*/
function rrwd_home_slider() {
global $wpdb;
@rianrietveld
rianrietveld / rrwd_upload_dir.php
Last active August 26, 2021 13:14
Add custom post type name to upload directory WordPress
<?php
/**
* Change Upload Directory for one Custom Post-Type
*
* This will change the upload directory for a custom post-type. Attachments for this custom post type will
* now be uploaded to a seperate "uploads" directory. Make
* sure you swap out "post-type" and the "my-dir" with the appropriate values...
* credits to: http://wordpress.stackexchange.com/users/4044/jhdenham
* and http://yoast.com/smarter-upload-handling-wp-plugins/
*/
@rianrietveld
rianrietveld / gist:4292303
Created December 15, 2012 09:14
Exclude by missing meta value in WordPress query is not logged in using the Members plugin
add_filter( 'pre_get_posts', 'rrwd_filter_posts' );
function rrwd_filter_posts( $query ) {
if( !is_user_logged_in() ) {
$meta_query = array(
array(
'key' => '_members_access_role',
'compare' => 'NOT EXISTS'
)
);
@rianrietveld
rianrietveld / wordpress-default-thumbnail.php
Created November 28, 2012 07:59
WordPress default thumbnail
<?php
// default thumbnail
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
function my_post_image_html( $html, $post_id, $post_image_id ) {
if( '' == $html )
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '"><img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/default-afbeelding.jpg" class="alignleft wp-post-image" alt="'.get_post_field( 'post_title', $post_id ).'"></a>';
else
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
return $html;
}