Skip to content

Instantly share code, notes, and snippets.

@dnnsldr
dnnsldr / WordPress .htaccess
Last active February 17, 2017 16:55
htaccess file for WordPress. Includes forcing www and/or https. Protects files and folders
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# require www and https
# comment out the first two if you do not need www
# comment out all lines for local dev
RewriteCond %{HTTP_HOST} !^www\. [NC]
/*CSS*/
@media only screen and (max-width: 500px) {
table, tr, td {
display: block; /* table-cell -> block */
width: 100%;
}
.main-col { display: table-header-group; }
.sub-col { display: table-footer-group; }
}
<!--HTML-->
<table> <!--“Desktop” width — 600px - 300*2-->
<tr>
<td class=”sub-col” width=”300”>...</td>
<td class=”main-col” width=”300”>...</td>
</tr>
</table>
@dnnsldr
dnnsldr / remove_slug_from_custom_post_type.php
Last active October 13, 2016 16:53 — forked from stefanbc/remove_slug.php
These functions remove the slug from a permalink for a custom post type. These should be placed in functions.php in your theme and the permalink structure should be /%postname%/
<?php
add_filter('post_type_link','custom_post_type_link',10,3);
function custom_post_type_link($permalink, $post, $leavename) {
$url_components = parse_url($permalink);
$post_path = $url_components['path'];
$path_base = explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) );
$post_name = ltrim( end( $path_base ), '/' );
if(!empty($post_name)) {
@dnnsldr
dnnsldr / upload_image_funtions.php
Created August 22, 2016 18:39
Wordpress: Adding conditions for image uploads on the custom post types. The dimensions can be set and will only allow those file dimensions to be uploaded.
/*-----------------------------------------------------------------------------------*/
// REQUIRE SIZES FOR ASSETS ON UPLOAD
/*-----------------------------------------------------------------------------------*/
add_filter('wp_handle_upload_prefilter','riester_handle_upload_prefilter');
function riester_handle_upload_prefilter($file) {
// see if we are trying to upload on a custom post type
if(get_post_type($_REQUEST['post_id']) == 'my_custom_post_type_name') {
// leave. this is wordpress stuff
@dnnsldr
dnnsldr / 0_reuse_code.js
Created June 25, 2016 00:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console