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 / 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 / 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 / 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 / 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 / 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