Skip to content

Instantly share code, notes, and snippets.

View blainerobison's full-sized avatar

Blaine Robison blainerobison

  • Dagrander
  • San Diego
View GitHub Profile
@blainerobison
blainerobison / .htaccess
Created March 30, 2016 18:03
Redirect / Rewrite Rules
# Rewrite url with or without trailing slash, case insensitive
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^path/?$ /new/path/ [NC,L,R=301]
</IfModule>
@blainerobison
blainerobison / functions.php
Created January 22, 2016 00:04
Use specific template when multiple post types defined via pre_get_posts hook.
<?php
/**
* Modify Main Query
*
* Add multiple post types to main query.
*
* @param object $query main query object
* @return no return value necessary.
*/
function _s_post_type_1_archive( $query ) {
@blainerobison
blainerobison / content.php
Created December 3, 2015 23:35
Add ShareThis social icons to WordPress
<div class="addthis_sharing_toolbox"></div>
@blainerobison
blainerobison / functions.php
Created November 19, 2015 00:15
Current WordPress URL
<?php echo esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); ?>
@blainerobison
blainerobison / functions.php
Created November 5, 2015 18:02
Remove default link to media file when adding to WYSIWYG editor in WordPress
<?php
/**
* Remove Link When Adding Media
*
* Adding media to a WYSIWYG editor can sometimes automatically include a link
* to the file. This sets the default behavior for all users to none.
*
* @return void
*/
function prefix_media_linking() {
@blainerobison
blainerobison / functions.php
Created October 8, 2015 17:57
Add Featured Image Description in WordPress
<?php
/**
* Add Featured Image Description
*
* @param string $content Admin post thumbnail HTML markup.
* @param integer $content Post ID.
* @return string
*/
function prefix_featured_image_description( $content, $post_id ) {
@blainerobison
blainerobison / setup.php
Created August 18, 2015 21:53
WordPress X-UA-Compatible Headers for IE
/**
* Set X-UA-Compatible for IE
*
* Sends headers to browser in an attempt to have IE render the website using
* their latest rendering engine (i.e. IE=edge). Additionally, attempts to
* activate Chrome Frame add-on if it exists.
*
* IE browser may show compatibility icon in address bar when using HTML5 Boilerplate's
* heading markup which contains conditional comments on HTML tag.
*
@blainerobison
blainerobison / functions.php
Created August 7, 2015 20:02
Disable Emoji output in WordPress.
<?php
/**
* Disable Emojis
*
* WordPress 4.2 introduced emoji JS and CSS in the page's head
*/
function prefix_disable_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
@blainerobison
blainerobison / .php
Last active August 29, 2015 14:26
Import Categories and Tags Into WordPress Post. Plugin: WP All Import
<?php
/**
* Import Categories and Tags Into Post
*
* Using WP CSV to export blog posts, taxonomy fields include slug (e.g. term:Term, another-term:Another Term)
* This will exclude slug, returning only term's name
*
* Example Usage: [prefix_import_term_name({tx_category[1]})]
* [prefix_import_term_name({tx_post_tag[1]})]
*
<?php
/**
* Hide Editor
*/
function prefix_hide_editor() {
// get post id
if ( isset( $_GET['post'] ) ) :
$post_id = $_GET['post'];