Skip to content

Instantly share code, notes, and snippets.

@taniarascia
taniarascia / toggle.js
Last active Aug 29, 2015
Toggle navigation with jQuery
View toggle.js
function toggleNav() {
if ($('#wrapper').hasClass('show-nav')) {
// Do things on Nav Close
$('#wrapper').removeClass('show-nav');
} else {
// Do things on Nav Open
$('#wrapper').addClass('show-nav');
}
//$('#wrapper').toggleClass('show-nav');
}
@taniarascia
taniarascia / sticky.js
Last active Aug 29, 2015
Navigation bar under header stick to top on scroll with jQuery
View sticky.js
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('div').addClass('stickyheader');
} else {
$('div').removeClass('stickyheader');
}
});
@taniarascia
taniarascia / .htaccess
Created Jul 9, 2015
Remove .php from filename
View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
@taniarascia
taniarascia / wp-main.php
Last active Aug 29, 2015
Common Wordpress queries
View wp-main.php
/*
the_ and get_the are two different queries. For example, the_title(); will echo out the title field into your HTML document, and get_the_title(); can be inserted into a value.
*/
<?php the_title(); ?> // Title
<?php the_content(); ?> // Full entry
<?php the_excerpt(); ?> // Partial entry
<?php the_permalink(); ?> // Calls a specific link
<?php the_category(); ?> // Calls the category
@taniarascia
taniarascia / random-image.php
Last active Aug 29, 2015
Call random image
View random-image.php
<?php
$random = rand(0, 2);
$picture = array(
'pic.jpg',
'other-pic.png',
'something.gif'
);
?>
<img src="<?php echo $picture[$random];?>"></a>
@taniarascia
taniarascia / echo-page-content.php
Last active Aug 29, 2015
Post the contents of one page on another page
View echo-page-content.php
<?php
$include = get_pages('include=6'); // Insert page number here
$content = apply_filters('the_content',$include[0]->post_content);
echo $content;
?>
@taniarascia
taniarascia / click-function.js
Created Jul 16, 2015
Call a function with a click event with jQuery
View click-function.js
$(function() {
$('.classname').click(function() {
// Calling a function in case you want to expand upon this.
clickFunction();
});
});
@taniarascia
taniarascia / overlay-color-div.css
Created Jul 25, 2015
Overlay a color and opacity to a background image
View overlay-color-div.css
.box {
width:350px;
height:150px;
}
.fade {
position: relative;
}
.fade:after {
@taniarascia
taniarascia / functions.php
Created Jul 27, 2015
Add meta to regular page post
View functions.php
// register your custom meta box
function my_slider_properties_meta_box() {
add_meta_box('my_slider_properties', 'Link Format Title URL', 'my_slider_properties', 'page', 'side', 'default');
}
add_action('add_meta_boxes', 'my_slider_properties_meta_box');
// echo your custom meta box
function my_slider_properties() {
global $post;
@taniarascia
taniarascia / thumbnail-function.php
Last active Aug 29, 2015
Force uploaded media to create a certain thumbnail size
View thumbnail-function.php
// Add 250 x 250 thumbnail to every image uploaded
add_image_size( 'gallery-thumbnail', 250, 250, true );
// gallery_thumbnail is a custom size! It can have any name.
// Call it later in a gallery loop.
<section id="gallery_page">
<ul class="gal columns-4">
<?php
$args = array(