Skip to content

Instantly share code, notes, and snippets.

@mzo84
mzo84 / get_posts.php
Last active August 16, 2016 07:08
Customizing the Loop with get_posts
<?php // additional loop via get_posts
global $post;
$args = array('category' => -9); // exclude Asides category
$custom_posts = get_posts($args);
foreach($custom_posts as $post) : setup_postdata($post);
...
endforeach;
?>
@mzo84
mzo84 / flexbox.css
Last active August 18, 2016 05:53
less damn code
// element margins
body * + * {
margin-top: 1.5rem;
}
// grid
.grid {
display: flex;
flex-flow: row wrap;
}
@mzo84
mzo84 / random-post.php
Created August 18, 2016 08:14
Wordpress - listing random possts
<?php // display random posts
$home_brew = new WP_Query('showposts=3&orderby=rand');
while($home_brew->have_posts()) : $home_brew->the_post();
// output custom stuff here! Post title, content, custom elds..
endwhile;
wp_reset_postdata();
?>
@mzo84
mzo84 / Enqueue-jQuery.php
Created August 18, 2016 08:17
Wordpress Enqueue jQuery
// Put this PHP code into your functions.php le.
// This will load the jQuery library onto your page by inserting a link in the <head> section where you call wp_head.
if(!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/
jquery/1.3.2/jquery.min.js"), false, '1.3.2');
wp_enqueue_script('jquery');
}
var link = document.createElement('a');
link.href = 'images.jpg';
link.download = 'Download.jpg';
document.body.appendChild(link);
link.click();