Skip to content

Instantly share code, notes, and snippets.

View samuelcotterall's full-sized avatar

Samuel Cotterall samuelcotterall

View GitHub Profile
/*
Learn to code with Kelis' Milkshake
http://en.wikipedia.org/wiki/Milkshake_(song)
Created by Brendan Dawes brendandawes.com
Modified by Samuel Cotterall samuelcotterall.com
*/
// "my milkshake brings all the boys to the yard"
var milkShake,
var userInfo = passport.deserializeUser(function(id){
return id;
});
User.findById(userInfo, function(err, user) {
});
function newsPost_block_func() {
global $post;
$args = array();
$query = new WP_Query($args);
var_dump($query->have_posts());
}
add_shortcode( 'newsPost_block', 'newsPost_block_func');
function newsPost_block_func() {
global $post;
$args = array(
'post_type' => array( 'post' ),
);
$query = new WP_Query($args);
var_dump($query->have_posts());
}
add_shortcode( 'newsPost_block', 'newsPost_block_func');
@samuelcotterall
samuelcotterall / Mark parent navigation active when on custom post type single page
Last active February 20, 2018 09:15 — forked from gerbenvandijk/Mark parent navigation active when on custom post type single page
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
@samuelcotterall
samuelcotterall / random-non-overlapping-position.js
Created September 16, 2017 20:20 — forked from magicznyleszek/random-non-overlapping-position.js
JavaScript -- get random non-overlapping position
// declarations
var positions = [];
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
// generate random positions