Skip to content

Instantly share code, notes, and snippets.

@kier0
kier0 / Remove related videos from Visual Composer Youtube embeds
Created August 31, 2017 21:52
Remove related videos from Visual Composer Youtube embeds
@kier0
kier0 / Wrap a certain character span
Created July 18, 2015 19:56
Wrap a certain character in a line of text in a span - to isolate and style. Example below is finding all the "i, I and ." in the text. ****NOTE**** Wordpress REMOVES backslashes needed to make a period read as a period and not a "wildcard". Must load this code in an external js file.
jQuery(document).ready(function() {
jQuery(".content-title p:contains('i')").html(function(_, html) {
return html.replace(/(i)/g, '<span class="pink">$1</span>');
});
// Pink I's
jQuery(".content-title p:contains('I')").html(function(_, html) {
return html.replace(/(I)/g, '<span class="pink">$1</span>');
});
@kier0
kier0 / Fade item on scroll up or down
Created July 17, 2015 22:21
Make top logo or nav fade on scroll down, and reappear on scroll up. var triggerHeight = 50; ---->>> is height of nav or logo so it downs face before you scroll past it. Scrolling up/down triggers class swap - use CSS to set opacity and animation
// Logo Fade
<?php wp_enqueue_script('jquery'); ?>
<script>
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var triggerHeight = 50;
jQuery(window).scroll(function(){
didScroll = true;
@kier0
kier0 / Revolution Slider Resize Zoom Fix
Last active August 29, 2015 14:22
Instructions: http://www.themepunch.com/faq/increase-size-of-text-on-mobile/ Add custom JS to "Custom JavaScript:" under "CSS/JavaScript" in the SLIDER SETTINGS Make sure to add CSS "transform-origin:center 0px!important;" to "span.zoom-this" so zooming doesn't move content to one side as it zooms.
span.zoom-this {
transform-origin:center 0px!important;
margin: 0px auto !important;
max-width: 100% !important;
display: block!important;
}
_______ THE JS ________
@kier0
kier0 / Sticky elements that stop at a certain distance from the bottom
Last active August 29, 2015 14:20
Sticky elements that stop at a certain distance from the bottom. Good for sticky items that should sit on top of the footer when it is in view.
jQuery(document).on("scroll",function(){
if(jQuery(window).scrollTop() + $(window).height() > $(document).height() - 60){
jQuery("div.sticky").addClass("stuck");
} else{
jQuery("div.sticky").removeClass("stuck");
}
});
@kier0
kier0 / change link to dial number on mobile screen
Created April 20, 2015 03:26
Change a button or link to trigger a phone app launch/number dial on a mobile screen size. Example below will change link on screens below 700px w.
@kier0
kier0 / Make any DIV a clickable link
Created March 19, 2015 08:22
Make any DIV a clickable link. Div must include a tag ( <a href=".."></a> ) This code will look for the first link tag inside the DIV Example below has 3 divs
@kier0
kier0 / Advanced Custom Fields for Alternate Styles
Last active August 29, 2015 14:16
Using Advanced Custom Fields for Alternate Styles that can be selected in Post/Page editor. This uses True/False Selection. If the selection in ACF is true, this code echos inline css styles. Change "no_banner_image" to whatever field name you created as an option.
<?php wp_enqueue_script('jquery'); ?>
<?php
if( get_field('no_banner_image') )
{
echo "
<style>
.class-one {
background:red
}
@kier0
kier0 / Wordpress - Get Page or Post
Last active August 29, 2015 14:15
Wordpress - Get Page or Post TITLE + CONTENT by ID (change 6 to id #)
<h1><?php echo get_the_title(6); ?> </h1>
<?php
$id=6;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
@kier0
kier0 / Remove Link from Image
Created February 12, 2015 02:10
Remove link from post thumbnail (or any image)