Skip to content

Instantly share code, notes, and snippets.

@adamlaki
adamlaki / .htaccess
Created October 14, 2017 17:52
With Apache deflate (which is an improved from Gzip) module you can quickly boost your site performance with some simple line.
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
@adamlaki
adamlaki / .htaccess
Created October 14, 2017 17:59
With the use of the expire module, you can set your assets browser cache time thus on the second download you can disable download of files like your site's favicon.
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 week"
# CSS
ExpiresByType text/css "access plus 2 week"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
@adamlaki
adamlaki / functions.php
Last active December 18, 2018 07:03
Remove Jetpack Related Post from Custom Post Types
<?php
function pine_jetpack_archive_no_related_posts( $options ) {
if ( is_post_type_archive( 'product' ) || ( get_post_type() == 'product' && is_single() ) ) {
$options['enabled'] = false;
}
return $options;
}
add_filter( 'jetpack_relatedposts_filter_options', 'pine_jetpack_archive_no_related_posts' );
@adamlaki
adamlaki / functions.php
Created June 30, 2018 16:05
Exclude Current Post from WP_Query
<?php
$args = array (
'post_type' => array( 'jobs' ),
'nopaging' => false,
'posts_per_page' => '5',
'ignore_sticky_posts' => false,
'post__not_in' => array(get_the_ID())
);
$query = new WP_Query( $args );
@adamlaki
adamlaki / functions.php
Created June 30, 2018 16:24
Add Favicon to Your WordPress Admin and Login
<?php
function add_favicon() {
$favicon_url = get_stylesheet_directory_uri() . '/assets/images/favicon/favicon-16x16.png';
echo '<link rel="shortcut icon" href="' . $favicon_url . '" />';
}
add_action('login_head', 'add_favicon');
add_action('admin_head', 'add_favicon');
@adamlaki
adamlaki / main.css
Created July 1, 2018 07:08
Custom Text Selection Style with ::selection
::-moz-selection {
background: #23A8B9;
color: #fff;
}
::selection {
background: #23A8B9;
color: #fff;
}
@adamlaki
adamlaki / main.css
Created July 1, 2018 07:27
Debugging Missing alt Attributes
img:not([alt]),
img[alt=""] {
outline: 5px solid red;
}
@adamlaki
adamlaki / index.html
Last active July 28, 2018 05:46
Set HTML5 Input's Placeholder Style with CSS
<form action="">
<input type="text" name="fname" placeholder="Your First Name">
</form>
@adamlaki
adamlaki / wp-config.php
Created October 8, 2018 15:01
Remove <p> Tag From Contact Form 7
define( 'WPCF7_AUTOP', false );
@adamlaki
adamlaki / content.php
Created December 8, 2018 06:36
Trim Any Text In WordPress by Words With wp_trim_words()
<div class="list-item">
...
<p class="list-item__excerpt">
<?php echo wp_trim_words( get_the_excerpt(), 25, '...' ); ?>
</p>
</div>