Skip to content

Instantly share code, notes, and snippets.

View wpexplorer's full-sized avatar
✍️
We create themes & plugins and run a popular blog about WordPress.

WPExplorer wpexplorer

✍️
We create themes & plugins and run a popular blog about WordPress.
View GitHub Profile
@wpexplorer
wpexplorer / gist:9608772
Created March 17, 2014 21:29
Alter fabulous featured image to link to itself
function wpex_post_featured_image() {
global $post;
if ( !has_post_thumbnail( $post->ID ) ) return;
if ( !get_theme_mod( 'wpex_blog_post_thumb', '1' ) ) return;
if ( 'on' == get_post_meta( $post->ID, 'wpex_disable_featured_image', true ) ) return; ?>
<div class="post-thumbnail">
<a href="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>" title="View Full Image"><img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" /></a>
</div><!-- .post-thumbnail -->
<?php
} // End function
@wpexplorer
wpexplorer / wordpress-attachments-search
Created March 20, 2014 01:21
Include Attachments in WordPress Search Results
@wpexplorer
wpexplorer / gist:9745941
Created March 24, 2014 18:17
Fabulous Display Sidebar on Homepage Always
if ( ! function_exists( 'wpex_sidebar_display' ) ) {
function wpex_sidebar_display() {
if ( is_front_page() ) return true; // Display sidebar on homepage no matter what.
if ( is_singular() ) {
global $post;
$post_layout = get_post_meta( $post->ID, 'wpex_post_layout', true );
if ( '' == $post_layout ) return true;
if ( 'right-sidebar' == $post_layout || 'left-sidebar' == $post_layout ) {
return true;
@wpexplorer
wpexplorer / wordpress-featured-image-alt
Created March 24, 2014 19:44
WordPress Featured Image Alt
@wpexplorer
wpexplorer / total-remove-portfolio-slug
Last active August 29, 2015 13:57
Remove Portfolio Slug From Total Theme
//Remove the slug from portfolio post type
function vipx_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'portfolio' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/'. wpex_option('portfolio_slug','portfolio-item') .'/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'vipx_remove_cpt_slug', 10, 3 );
function vipx_parse_request_tricksy( $query ) {
// Only noop the main query
<FilesMatch ".(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
@wpexplorer
wpexplorer / gist:10074838
Created April 7, 2014 23:53
WordPress oembed wpmode transparent
function add_video_wmode_transparent($html, $url, $attr) {
if ( strpos( $html, "<embed src=" ) !== false )
{ return str_replace('</param><embed', '</param><param name="wmode" value="opaque"></param><embed wmode="opaque" ', $html); }
elseif ( strpos ( $html, 'feature=oembed' ) !== false )
{ return str_replace( 'feature=oembed', 'feature=oembed&wmode=opaque', $html ); }
else
{ return $html; }
}
add_filter( 'embed_oembed_html', 'add_video_wmode_transparent', 10, 3);
@wpexplorer
wpexplorer / gist:11390068
Created April 29, 2014 03:32
remove-ultra-responsive-css
function remove_ultra_responsive_css() {
wp_dequeue_style( 'wpex-responsive' );
}
add_action( 'wp_print_styles', 'remove_ultra_responsive_css' );
if ( ! function_exists( 'wpex_embed_oembed_html' ) ) {
function wpex_embed_oembed_html($html, $url, $attr, $post_id) {
return '<div class="responsive-video-wrap entry-video">' . $html . '</div>';
}
}
add_filter('embed_oembed_html', 'wpex_embed_oembed_html', 99, 4);
<form role="search" method="get" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="search" class="field" name="s" value="<?php _e( 'search', 'wpex' ); ?>" placeholder="<?php _e( 'search', 'wpex' ); ?>"
</form>