Skip to content

Instantly share code, notes, and snippets.

@web-architecture-solutions
web-architecture-solutions / .htaccess
Last active September 5, 2018 05:31
WordPress | Example .htaccess
# Source: https://premium.wpmudev.org/blog/shun-the-plugin-100-wordpress-code-snippets-from-across-the-net/
<Files wp-config.php>
order allow,deny
deny from all
</Files>
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
@web-architecture-solutions
web-architecture-solutions / wp-include-jquery.php
Last active September 5, 2018 05:31
WordPress | Include jQuery
/*
* Source: https://premium.wpmudev.org/blog/shun-the-plugin-100-wordpress-code-snippets-from-across-the-net/
*/
<?php wp_enqueue_script("jquery"); ?>
@web-architecture-solutions
web-architecture-solutions / wp-change-excerpt-length.php
Last active September 5, 2018 05:31
WordPress | Change Excerpt Length
/*
* Source: https://premium.wpmudev.org/blog/shun-the-plugin-100-wordpress-code-snippets-from-across-the-net/
* Documentation: https://developer.wordpress.org/reference/hooks/excerpt_length/
*/
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
@web-architecture-solutions
web-architecture-solutions / wp-tag-cloud.php
Created September 4, 2018 22:27
WordPress | Tag Cloud
/*
* Source: https://premium.wpmudev.org/blog/shun-the-plugin-100-wordpress-code-snippets-from-across-the-net/
* Documentation: https://developer.wordpress.org/reference/functions/wp_tag_cloud/
*/
wp_tag_cloud(array(
'smallest' => 10, // size of least used tag
'largest' => 18, // size of most used tag
'unit' => 'px', // unit for sizing
'orderby' => 'name', // alphabetical
@web-architecture-solutions
web-architecture-solutions / wp-custom-shortcode.php
Last active September 5, 2018 05:31
WordPress | Custom Shortcode Boilerplate
/*
* Source: https://speckyboy.com/wordpress-snippets-extend-wordpress/
* Documentation: https://developer.wordpress.org/reference/functions/add_shortcode/
*/
function helloworld() {
return 'Hello World!';
}
add_shortcode('hello', 'helloworld');
@web-architecture-solutions
web-architecture-solutions / wp-singleton-redirect.php
Created September 4, 2018 22:37
WordPress | Singleton Redirect
/*
* Redirect to a single WordPress post if there's only one in/with a given category/tag
* Source: https://speckyboy.com/wordpress-snippets-extend-wordpress/
* Documentation: https://developer.wordpress.org/reference/hooks/template_redirect/
*/
function stf_redirect_to_post(){
global $wp_query;
// If there is one post on archive page
if( is_archive() && $wp_query->post_count == 1 ){
@web-architecture-solutions
web-architecture-solutions / wp-list-scheduled-posts.html
Created September 4, 2018 22:41
WordPress | List Scheduled Posts
<?php
/*
* Source: https://speckyboy.com/wordpress-snippets-extend-wordpress/
*/
?>
<?php
$my_query = new WP_Query('post_status=future&order=DESC&showposts=5');
if ($my_query->have_posts()) {
<ul>
/*
* Based on Eric Meyer's reset: https://meyerweb.com/eric/tools/css/reset/
* Source: https://www.hongkiat.com/blog/css-snippets-for-designers/
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
/*
* Based on Nicolas Gallagher's micro clearfix hack
*/
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@web-architecture-solutions
web-architecture-solutions / breakpoint-boilerplate.css
Created September 4, 2018 23:31
CSS | Breakpoint Boilerplate
/*
* Adapted from this article on CSS-Tricks: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px) and (max-device-width : 480px) {
  /* Styles */
}