Skip to content

Instantly share code, notes, and snippets.

@nickberens360
nickberens360 / wordpress: elseif format.php
Last active March 9, 2016 19:33
Nice PHP/WP elseif format
<?php if (is_category('a')) { ?>
<!-- code here -->
<?php } elseif (is_category(array('b','c'))) { ?>
<!-- code here -->
<?php } elseif (is_category('d')) { ?>
<!-- code here -->
<?php } else { ?>
@nickberens360
nickberens360 / wordpress: Title tag
Last active August 29, 2015 14:11
Wordpress: Title Tag
<title>
<?php
if (function_exists('is_tag') && is_tag()) { echo 'Tag Archive for &quot;'.$tag.'&quot; - '; }
elseif (is_archive()) { wp_title(''); echo ' Archive - '; }
elseif (is_front_page()) { wp_title(''); }
elseif (is_search()) { echo 'Search for &quot;'.wp_specialchars($s).'&quot; - '; }
elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; }
elseif (is_404()) { echo 'Not Found - '; } bloginfo('name');
?>
</title>
@nickberens360
nickberens360 / WP: Repeater field values from Options.php
Last active March 17, 2017 13:47
WP: Repeater field values from Options
<?php if(get_field('service_areas', 'option')): ?>
<?php while(has_sub_field('service_areas', 'option')): ?>
<li><?php the_sub_field('service_area'); ?></li>
<?php endwhile; ?>
<?php endif; ?>
@nickberens360
nickberens360 / blog.iml CSS
Created January 5, 2015 14:54
blog.iml CSS
.blog-body {
border-right: 2px dotted #DCDCDC;
padding-right: 24px;
}
#bread {
display: none;
}
.blog-main {
@nickberens360
nickberens360 / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
ul {
list-style: none;
padding:0;
margin:0;
}
li {
padding-left: 1em;
text-indent: -.7em;
}
@nickberens360
nickberens360 / new_gist_file.php
Created June 10, 2015 15:25
Bootstrap: dynamically add carousel indecators ***PHP VERSION***
<ol class="carousel-indicators slideNav">
<?php if( have_rows('slide') ): ?>
<? $i = 0; ?>
<?php while ( have_rows('slide') ) : the_row(); ?>
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $i; ?>" class="<? if($i === 0): ?>active<? endif; ?>"></li>
<? $i++; ?>
<?php endwhile; ?>
<?php endif; ?>
</ol>
@nickberens360
nickberens360 / new_gist_file.php
Created June 12, 2015 17:29
wordpress: add masonry to wp
if (! function_exists('slug_scripts_masonry') ) :
if ( ! is_admin() ) :
function slug_scripts_masonry() {
wp_enqueue_script('masonry');
wp_enqueue_style('masonry', get_template_directory_uri().'/css/');
}
add_action( 'wp_enqueue_scripts', 'slug_scripts_masonry' );
endif; //! is_admin()
endif; //! slug_scripts_masonry exists
@nickberens360
nickberens360 / new_gist_file.php
Last active September 28, 2021 20:46
wordpress: Full dynamic bootstrap carousel code
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
$args = array(
'post_type' => 'slides1',
'orderby' => 'menu_order title',
'order' => 'ASC',
);
$query = new WP_Query( $args );
@nickberens360
nickberens360 / new_gist_file.js
Created June 24, 2015 20:16
jQuery: Check if click outside of element
$(document).mouseup(function (e)
{
var container = $('#js-searchPane');
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.removeClass('searchPane-open');
}
});