Skip to content

Instantly share code, notes, and snippets.

View jayontraps's full-sized avatar

Jason Righelato jayontraps

  • London, UK
View GitHub Profile
@jayontraps
jayontraps / Sass define columns - grid mixin
Created April 27, 2019 05:41
sass mixin define columns
@mixin defineCols($numPerRow, $margin) {
width: ((100% - (($numPerRow - 1) * $margin)) / $numPerRow);
&:nth-child(n) {
margin-bottom: $margin;
margin-right: $margin;
}
&:nth-child(#{$numPerRow}n) {
margin-right: 0;
margin-bottom: 0;
}
@jayontraps
jayontraps / React.createClass()
Last active October 28, 2015 21:23
React.createClass()
var Helloworld = React.createClass({
render: function() {
return (
<div>Hello Wold</div>
);
}
});
ReactDOM.render(<Helloworld />, document.body);
<?php
$args = array(
// arguments for your query
'post_type' => '',
'posts_per_page'=> -1,
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
// the query
$the_query = new WP_Query( $args ); ?>
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
(function($,window){
window.getActiveMQ = function()
{
$('<div id="getActiveMQ-watcher"></div>')
.appendTo('body')
.hide();
var computed = window.getComputedStyle,
watcher = document.getElementById('getActiveMQ-watcher');
/* Mobile first queries */
/* Larger than mobile */
@media (min-width: 400px) {}
/* Larger than phablet */
@media (min-width: 550px) {}
/* Larger than tablet */
@media (min-width: 750px) {}
@jayontraps
jayontraps / wp: get theme dircetory
Created November 30, 2014 19:58
Wordpress get theme dircetory
<?php echo get_stylesheet_directory_uri(); ?>
@jayontraps
jayontraps / wp: get root dircetory
Created November 30, 2014 19:57
Wordpress get root dircetory
<?php bloginfo('url'); ?>
@jayontraps
jayontraps / wp: get custom post type archive listing by year
Created November 30, 2014 19:56
Wordpress wp: get custom post type archive listing by year
// example 'news' cpt
function myquery_custom_post_rewrite( $rewrite_rules ) {
$pagination_base = $GLOBALS['wp_rewrite']->pagination_base;
$myqueryslug = 'news';
$year_archive = array(
$myqueryslug . '/([0-9]{4})/' . $pagination_base . '/?([0-9]{1,})/?$' => 'index.php?post_type=' . $myqueryslug . '&year=$matches[1]&paged=$matches[2]',
$myqueryslug . '/([0-9]{4})/?$' => 'index.php?post_type=' . $myqueryslug . '&year=$matches[1]',
);
$rewrite_rules = $year_archive + $rewrite_rules;
define('DISALLOW_FILE_EDIT', true);
/* That's all, stop editing! Happy blogging. */