This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function search_url_rewrite_rule() { | |
if ( is_search() && !empty($_GET['s'])) { | |
wp_redirect(home_url("/search/") . urlencode(get_query_var('s'))); | |
exit(); | |
} | |
} | |
add_action('template_redirect', 'search_url_rewrite_rule'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load media files from production server if they don't exist locally | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{HTTP_HOST} ^localsite\.dev$ | |
RewriteRule ^wp-content/uploads/(.*)$ http://remotesite.com/wp-content/uploads/$1 [NC,L] | |
</IfModule> | |
# Another way |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.faq-filter').submit(function(event){ | |
// get values and join them with comma | |
var vals = $('input[type="checkbox"]:checked').map( | |
function(i){ | |
return $(this).val(); | |
}).get().join(','); | |
// push values to hidden field | |
$('#faq-cats').val(vals); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Extend get terms with post type parameter. | |
* | |
* @global $wpdb | |
* @param string $clauses | |
* @param string $taxonomy | |
* @param array $args | |
* @return string | |
*/ | |
function custom_terms_clauses( $clauses, $taxonomy, $args ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper function to check if we edit front page | |
* @param type $cmb | |
* @param type $cmb | |
* @return type | |
*/ | |
function cmb2_show_if_front_page( $cmb ) { | |
// Don't show this metabox if it's not the front page template | |
if ( $cmb->object_id !== get_option( 'page_on_front' ) ) { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Usage for the built in 'post' post type: | |
* unregister_post_type( 'post', 'edit.php' ); | |
*/ | |
function deregister_post_type() { | |
global $wp_post_types; | |
$post_type = 'post'; | |
if ( isset( $wp_post_types[ $post_type ] ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.full-width { | |
width: 100vw; | |
position: relative; | |
left: 50%; | |
right: 50%; | |
margin-left: -50vw; | |
margin-right: -50vw; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disable_wp_emojicons() { | |
// all actions related to emojis | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); | |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Hide WP version strings from scripts and styles | |
* @return {string} $src | |
* @filter script_loader_src | |
* @filter style_loader_src | |
*/ | |
function mu_remove_wp_version_strings( $src ) { | |
global $wp_version; | |
parse_str( parse_url( $src, PHP_URL_QUERY ), $query ); | |
if ( !empty( $query['ver'] ) && $query['ver'] === $wp_version ) { |
OlderNewer