Skip to content

Instantly share code, notes, and snippets.

// Markup Sample
<img src="<?php echo $image[0]; ?>"
width="<?php echo $image[1]; ?>"
height="<?php echo $image[2]; ?>"
alt="<?php echo $image_alt; ?>" />
// Markup Sample (Media Query Sync)
<figure>
<img class="responsive"
src="<?php echo $media_sml[0]; ?>"
@besimhu
besimhu / rem() function snippet
Created March 15, 2015 16:29
Snippets to use rem() function. Simply go to 'Tools -> New Snippet' and add your snippets in. To use hit tab after writing 'rm'
<snippet>
<content><![CDATA[
rem(${1});
]]></content>
<tabTrigger>rm</tabTrigger>
</snippet>
@besimhu
besimhu / em() function snippet
Created March 15, 2015 16:28
Snippets to use em() function. Simply go to 'Tools -> New Snippet' and add your snippets in. To use hit tab after writing 'em'.
<snippet>
<content><![CDATA[
em(${1});
]]></content>
<tabTrigger>em</tabTrigger>
</snippet>
@besimhu
besimhu / @include rem() mixin snippet
Last active August 29, 2015 14:17
Enables the use of rem mixin. This mixin takes two values, the first being a css property, and the second being your size values. You're able to use any unit you desire, and it will convert it over. Please note that this mixin also comes with a pixel fallback, and this mixin mostly comes in handy when you are needing to have IE8 support, but sti…
<snippet>
<content><![CDATA[
@include rem(${1}, ${2});
]]></content>
<tabTrigger>rem</tabTrigger>
</snippet>
@besimhu
besimhu / Media Query Snippet (SCSS)
Created March 15, 2015 16:16
Snippet to write out media queries faste. Go to 'Tools -> New Snippet' to add your snippet. Use by typing 'mq' followed by Tab until it's filled out.
<snippet>
<content><![CDATA[
@include mq(${1}) {
${2}
}
]]></content>
<tabTrigger>mq</tabTrigger>
</snippet>
@besimhu
besimhu / Rewrite Author Slug.php
Created March 15, 2015 16:07
For when you want something other than /author
// Rewrite author slug
function change_author_permalinks() {
global $wp_rewrite;
$wp_rewrite->author_base = 'people';
$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
}
add_action('init','change_author_permalinks');
@besimhu
besimhu / Remove Admin Bar Margin.php
Created March 15, 2015 16:06
Sometimes if you have a site with a lot of fixed elements, the admin bar sure can be a pain. This removes the margin that gets added.
// Remove Admin Bar Margin
add_action('get_header', 'my_filter_head');
function my_filter_head() {
remove_action('wp_head', '_admin_bar_bump_cb');
}
@besimhu
besimhu / Show Custom Post Types in Tag Search.php
Created March 15, 2015 16:06
When you view a tag, it only lists custom post type with ‘post’ … this function changes that.
// Allow custom post types in tag search
function post_type_tags_fix($request) {
if ( isset($request['tag']) && !isset($request['post_type']) )
$request['post_type'] = 'any';
return $request;
}
add_filter('request', 'post_type_tags_fix');
@besimhu
besimhu / Check if it’s part of the blog.php
Created March 15, 2015 16:05
Sometimes you just want to have one check that checks if it’s related to the blog. Yes, this uses many functions, so use it as a last resort.
// check if it's a blog page
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') );
}
@besimhu
besimhu / Remove jump from <-more-> tag.php
Last active August 29, 2015 14:17
Sometimes you want to use the <-more-> tag to link to the full post. That being said, the only problem with that is that it jumps to the part where the tag was added. Here a function that removes the jump.
// Remove jump with <-more-> tag
function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) { $end = strpos($link, '"',$offset); }
if ($end) { $link = substr_replace($link, '', $offset, $end-$offset); }
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');