Skip to content

Instantly share code, notes, and snippets.

View rianrietveld's full-sized avatar

Rian Rietveld rianrietveld

View GitHub Profile
@rianrietveld
rianrietveld / wpacc_skip_links.css
Created September 25, 2012 09:52
WordPress Genesis Accessible skip links
@rianrietveld
rianrietveld / wpacc_search_form_header.css
Created November 22, 2012 05:44
WordPress Genesis searchform with label and hook for genesis_header_right
.prefix-hidden {
background-color: #fff;
border: 1px solid #000;
display: block;
font-size: 1em;
left: -1000em;
padding: 0.8em;
position: absolute;
z-index: 10;
}
@rianrietveld
rianrietveld / rrwd_custom_post_type_with_taxonomy.php
Created November 22, 2012 06:43
WordPress costom post type with it's own taxonomy. Also adds an archive option to show the posts ordered by taxonomy name
<?php
/**
* This code adds a costom post type with it's own taxonomy to WordPress
* And adds an archive option to show the posts ordered by taxonomy name
* Rian Rietveld - rrwd.nl
* November 22, 2012
* Add this to the functions.php in your WordPress child theme
* Here, as an example, the custom post type is book and the taxonony is genre
*/
@rianrietveld
rianrietveld / rrwd_save_cpf_with_ctp.php
Created November 22, 2012 07:21
Save an extra custom post field in custom post type in WordPress
<?php
/**
* This code saves an extra custom post field with a custom post type to WordPress
* Rian Rietveld - rrwd.nl
* Add this to the functions.php in your WordPress child theme
*
* Adding the priority 20 for the add_action to save_post is !important, otherwise it won't work
*/
function rrwd_save_cpf_with_ctp ( $post_id, $post ) {
@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;
}
@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 / 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 / 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 / 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="Twitter-banner@2x.png" alt="Follow me on Twitter"></a>
@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;
}
?>