Skip to content

Instantly share code, notes, and snippets.

View j-cam's full-sized avatar

Jamie Campbell j-cam

View GitHub Profile
@j-cam
j-cam / ACF-2-Columns-Repeater-Field.php
Last active August 29, 2015 14:03
Create 2 equal columns of grid items from an Advanced Custom Fields repeater field. The left column will contain more items if the number of results is an odd number.
<div class="row">
<?php
// ACF_REPEATER_FIELD_NAME Repeater
if( get_field( 'ACF_REPEATER_FIELD_NAME' ) ):
// Get number of items from the result
$numItems = sizeof( get_field( 'ACF_REPEATER_FIELD_NAME' ) );
// Divied by 2 and round up to distribute evenly between the columns
$itemsPerColumn = round( $numItems/2 );
// Intialize an iterator for displacing an odd number of results
@j-cam
j-cam / disable-infinite-scroll.php
Last active August 29, 2015 14:19
Wordpress: Disable Infinite Scroll for custom post type archives and set posts_per_page
if ( ! function_exists( 'cpt_archives_settings' ) ) :
add_action( 'pre_get_posts', 'themename_cpt_archives_settings' );
// Pass the $query argument into the action.
function themename_cpt_archives_settings( $query ) {
// Define the context.
// Not on dashboard pages when inside the main query only on cpt archives.
if( ! is_admin() && $query->is_main_query() && is_post_type_archive( 'cpt_name_goes_here' ) ) {
@j-cam
j-cam / page.php
Created April 16, 2015 07:19
Wordpress: Contextually load content template parts for pages via get_template_part().
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* Additionally this template will try to retrieve the any
@j-cam
j-cam / acf-yoast-seo.php
Created May 29, 2015 04:40
Add Advanced Custom Fields to Yoast SEO keyword density filter.
<?php
/**
* Add ACF Fields to Keyword evaluation for Yoast SEO Plugin
* @link https://imperativeideas.com/making-custom-fields-work-yoast-wordpress-seo/
*/
if ( is_admin() && defined('WPSEO_VERSION') ) { // check to make sure we aren't on the front end
add_filter('wpseo_pre_analysis_post_content', 'add_acf_to_yoast');
@j-cam
j-cam / SassMeister-input-HTML.html
Last active August 29, 2015 14:23
Generated by SassMeister.com.
<header>Header</header>
<nav>Nav</nav>
<article>Article</article>
<footer>Footer</footer>
@j-cam
j-cam / SassMeister-input-HTML.html
Created June 24, 2015 05:43
Generated by SassMeister.com.
<nav class="site-nav">
<ul class="main-menu">
<li class="main-menu__item main-menu__item_home">
<a class="main-menu__anchor" href="#">HOME</a>
</li>
<li class="main-menu__item main-menu__item_products">
<a class="main-menu__anchor" href="#">PRODUCTS</a>
</li>
<li class="main-menu__item main-menu__item_about">
<a class="main-menu__anchor" href="#">ABOUT</a>
@j-cam
j-cam / jr-photo-set-slides-script.txt
Last active August 29, 2015 14:24
Script for setting slideshow options and adding arrow key functionality for photo set pages.
<!-- START SLIDE FUNCTIONALITY -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/storage/js/slides.jquery.js"></script>
<script>
$(function () {
$('#slides').slides({
preload: true,
preloadImage: '/storage/js/loading.jpg',
autoHeight: true,
autoHeightSpeed: 350,
@j-cam
j-cam / jr-photo-set-template.txt
Created July 8, 2015 16:02
Template for creating a new photo set post.
<!-- START SLIDE FUNCTIONALITY -->
<script type src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="/storage/js/slides.jquery.js"></script>
<script>
$(function () {
$('#slides').slides({
preload: true,
preloadImage: '/storage/js/loading.jpg',
autoHeight: true,
autoHeightSpeed: 350,
@j-cam
j-cam / wp-post-image-regulator.css
Created January 26, 2016 08:05
Wordpress: Removing Image and Caption Dimension Attributes.
/* Attribution: http://wordpress.stackexchange.com/a/37768/35516 */
.entry-content img,
.comment-content img,
.widget img {
max-width: 97.5%; /* Fluid images for posts, comments, and widgets */
}
img[class*="align"],
img[class*="wp-image-"] {
height: auto; /* Make sure images with WordPress-added height and width >attributes are scaled correctly */
}
@j-cam
j-cam / wp_default_styles_version.php
Last active March 19, 2016 19:10
A function for updating the version in the query string for a theme's default stylesheet.
<?php
/**
* Updates the v= query string for
* theme's default stylesheet for
* browser cache busting etc.
*/
function theme_wp_default_styles_version($styles) {
// use date versioning or semantic versioning