Skip to content

Instantly share code, notes, and snippets.

@matthiaspabst
matthiaspabst / wordpress-post-thumbnail-grid-style.css
Last active May 13, 2021 03:16
WordPress page template for a post thumbnail grid
/* Post Thumbnail Grid */
.gridcontainer h2 a{color: #333; font-size: 13px;}
.gridcontainer .griditemleft{float: left; width: 150px; margin: 0 30px 20px 0;}
.gridcontainer .griditemright{float: left; width: 150px;}
.gridcontainer .postimage{margin: 0 0 5px 0;}
.gridcontainer .postimage-title {text-align: center;}
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@matthiaspabst
matthiaspabst / dl-file.php
Last active April 5, 2016 14:44
Hide media files for non-logged-in users in WordPress
<?php //Credits: http://0to5.com/protecting-wordpress-media-uploads-unless-user-is-logged-in/
require_once('wp-load.php');
If (!is_user_logged_in()){
$upload_dir = wp_upload_dir();
echo $upload_dir['baseurl'] . '/' . $_GET[ 'file' ];
wp_redirect( wp_login_url( $upload_dir['baseurl'] . '/' . $_GET[ 'file' ]));
exit();
}
list($basedir) = array_values(array_intersect_key(wp_upload_dir(), array('basedir' => 1)))+array(NULL);
@matthiaspabst
matthiaspabst / 404.php
Created February 28, 2017 09:39
Twenty Fifteen - Default 404 Page
<?php
/**
* The template for displaying 404 pages (not found)
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
get_header(); ?>
@matthiaspabst
matthiaspabst / 404.php
Last active April 14, 2022 12:32
Twenty Fifteen - Custom 404 page for a custom post type
<?php
/**
* The template for displaying 404 pages (not found)
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
get_header(); ?>
@matthiaspabst
matthiaspabst / gravityforms-antispam.php
Created October 24, 2019 09:36
Gravity Forms Antispam
<?php
/**
* Gravity Forms Antispam
* Check if field has a predefined value
* https://docs.gravityforms.com/gform_field_validation/#1-number-field-validation
*/
function gf_antispam( $result, $value, $form, $field ) {
if ( $result['is_valid'] && intval( $value ) !== 9 ) {