Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / gist:5343960
Last active December 15, 2015 23:59
Show Posts in the Current month - currently, not working like it should do, just shows all dates that are in the future past the current time.
<div class="sixcol first">
<h2>This Month</h2>
<?php
//This gets the current month starting at day 1, and the next month starting at day 1
$now = mktime(0, 0, 0, date("m"), 1, date('Y'));
$then = mktime(0, 0, 0, (date("m") % 12 + 1), 1, date('Y'));
query_posts(
@yratof
yratof / gist:5442018
Last active December 16, 2015 13:29
Imagemagick convert PDF to JPG
<?php
if ( !file_exists( $dest_path ) ) {
$myurl = $file_path.'[0]';
$image = new Imagick($myurl);
$image->setResolution( 300, 300 );
$image->setImageFormat( "png" );
$image->writeImage($dest_path);
};
?>
@yratof
yratof / gist:5442649
Created April 23, 2013 10:59
PDF in a widget that has a thumbnail of the front page
// THIS IS A RISK. CONVERT PDF's TO JPG FOR THUMBNAILS.
// Seriously hope it works
function load_pmg_single_doc() {
register_widget('PMG_Single_Doc');
}
add_action('widgets_init', 'load_pmg_single_doc');
class PMG_Single_Doc extends WP_Widget {
@yratof
yratof / loops
Created April 30, 2013 20:39
Wordpress, 2 loops of one post. Linked together by fate.
<section class="tab-navigation">
<ul class="tabs">
<?php // This is the jquery loop part. it's clever, so look carefully at what happens
wp_reset_query();
$posttype = 'post'; //<------- Change your post type here
// Query whatever you need, for this, i'll be using a custom post type.
$displayposts = new WP_Query();
$displayposts->query('post_type='.$posttype.'&order=asc');
var jbtle = jQuery(".jobtitle a").text();
jQuery(document).ready(function($){
$(".jobtitle a").each(function(){
$(this).click(function (){
$("#thejobtitle").html(jbtle);
});
});
});
@yratof
yratof / gist:5772752
Created June 13, 2013 10:27
Opencart: List of categories
<?php if ($categories) { ?>
<div class="category-list">
<?php if (count($categories) <= 4) { ?>
<ul class="categoryRow twelvecol clearfix first">
<?php foreach ($categories as $category) { ?>
<li class="threecol clearfix first img">
<?php if ($category['thumb']) { ?>
<a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" alt="<?php echo $category['name']; ?>" /></a>
<?php } ?>
<?php
$classes = array(' first', '' , '', ' last');
if ($categories) { ?>
<div class="category-list">
<?php if (count($categories) <= 4) { ?>
<ul class="categoryRow twelvecol clearfix first">
<?php foreach ($categories as $category) { ?>
<li class="threecol clearfix first img">
<?php if ($category['thumb']) { ?>
.notice{
$colours: pink $pink, orange $orange, teal $teal;
@each $colour in $colours {
&.#{nth($colour, 1)} {
background: nth($colour, 2);
h3{
color: $white;
@yratof
yratof / gist:5849150
Created June 24, 2013 10:26
Update your repo if you change your username
g remote set-url origin git@bitbucket:/#new-url#/repo.git
@yratof
yratof / gist:5851424
Created June 24, 2013 16:32
Wordpress loop to list posts by day of the week
<?php //This gets the current month starting at day 1, and the next month starting at day 1
$now = mktime(0, 0, 0, date("m"), 1, date('Y'));
$then = mktime(0, 0, 0, (date("m") % 12 + 1), 1, date('Y'));
query_posts(
array(
'post_type' => 'classes', // Custom Post Type
'order' => 'asc', // Order with earliest first
'orderby' => 'wpcf-date-and-time', // Order by the custom field
'posts_per_page' => -1, // Show all