Skip to content

Instantly share code, notes, and snippets.

@stefthoen
stefthoen / wp-pagination.php
Created November 29, 2012 14:29
Adds pagination to WordPress without a plugin (taken from HTML5-Blank-WordPress-Theme)
// Add to functions.php
// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function html5wp_pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
@stefthoen
stefthoen / wp-config.php
Created December 17, 2012 17:26
Configure a local and a site database in wp-config.php.
if ($_SERVER['HTTP_HOST'] == 'localhost:8888') {
define('DB_NAME', 'stefvork_database');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');
} else {
define('DB_NAME', 'baardbaard_domein');
define('DB_USER', 'baardbaard_user');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
@stefthoen
stefthoen / deploy.php
Created December 20, 2012 07:18
Git deploy script howto: 1) Add post service hook in Bitbucket: https://confluence.atlassian.com/display/BITBUCKET/POST+Service+Management. 2) Add a deployment key: https://confluence.atlassian.com/display/BITBUCKET/Using+Deployment+Keys 3) Install script in root of web app 4) Configure script (see 1) 5) Push to Bitbucket! Bonus: Configure wp-co…
<?php
// Source: http://brandonsummers.name/blog/2012/02/10/using-bitbucket-for-automated-deployments/
date_default_timezone_set('Europe/Amsterdam');
class Deploy {
/**
* A callback function to call after the deploy has finished.
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@stefthoen
stefthoen / wp-config.php
Created April 8, 2013 11:28
Add this code to wp-config.php. Now I can open any page, and if something goes wrong there, like a white screen of death, I add ?debug=debug to its URL and see what’s causing the trouble.
if ( isset($_GET['debug']) &amp;&amp; $_GET['debug'] == 'debug')
define('WP_DEBUG', true);
@stefthoen
stefthoen / functions.php
Last active October 9, 2024 00:33
WordPress function to create picturefill HTML.
function get_responsive_image($id, $src, $alt = "") {
$large = wp_get_attachment_image_src( $id, 'large' );
$medium = wp_get_attachment_image_src( $id, 'medium' );
$small = wp_get_attachment_image_src( $id, 'thumbnail' );
$output = '<div class="img-responsive">';
$output.= ' <div data-picture data-alt="' . $alt . '">';
$output.= ' <div data-src="' . $small[0] . '"></div>';
$output.= ' <div data-src="' . $medium[0] . '" data-media="(min-width: 786px)"></div>';
$output.= ' <div data-src="' . $large[0] . '" data-media="(min-width: 920px)"></div>';
@stefthoen
stefthoen / retina-mixin.scss
Last active December 20, 2015 10:19
Sass mixin for retina images.
@mixin at2x($image_name, $w: auto, $h: auto, $extention: '.png') {
background-image: image-url($image_name + $extention);
$x2img : $image_name + '@2x' + $extention;
@media screen and (-webkit-min-device-pixel-ratio : 1.5) {
background-image: image-url($x2img);
background-size: $w $h;
}
}
@stefthoen
stefthoen / .gitignore
Last active December 20, 2015 16:59 — forked from redoPop/.gitignore
Gitignore for WordPress.
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "plugins"
# and "themes" directories.
wp-content/*
!wp-content/plugins/
!wp-content/themes/
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml text/css application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
@stefthoen
stefthoen / .htaccess
Created August 10, 2013 11:38
.htaccess for WordPress.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache config if possible
# httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com