Skip to content

Instantly share code, notes, and snippets.

@astockwell-ps
astockwell-ps / PHP Setup WP Custom Taxonomy with hierarchical URLs (tldparent_termchild_term...)
Created September 7, 2012 17:49
PHP: Setup WP Custom Taxonomy with hierarchical URLs (tld/parent_term/child_term/...)
<?php
// via http://wordpress.stackexchange.com/questions/17325/how-to-enable-hierarchical-permalinks-for-hierarchical-taxonomies
// and http://wordpress.org/support/topic/hierarchical-custom-taxonomy-permalinks
register_taxonomy('genre',array('book'), array(
'hierarchical' => true, // this makes it hierarchical in the UI
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'hierarchical' => true ), // this makes hierarchical URLs
@astockwell-ps
astockwell-ps / MySQL: Add featured image to post (post-thumbnail)
Created August 16, 2012 20:16
MySQL: Add featured image to post (post-thumbnail)
LOCK TABLES `wp_postmeta` WRITE;
/*!40000 ALTER TABLE `wp_postmeta` DISABLE KEYS */;
INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`)
VALUES
(47059,4635,'_thumbnail_id','4705'),
(47060,4635,'_thumbnail_id','4708');
/*!40000 ALTER TABLE `wp_postmeta` ENABLE KEYS */;
UNLOCK TABLES;
@astockwell-ps
astockwell-ps / htaccess: Expiring Entity Tags
Created July 26, 2012 16:04
htaccess: Expiring Entity Tags
# BEGIN Entity Tag Expiration: http://stuntsnippets.com/etags-htaccess/
FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|gif|png|ico|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</filesmatch>
</ifmodule>
# End Entity Tag
@astockwell-ps
astockwell-ps / PHP: WP: Turn on error reporting
Created May 11, 2012 18:09
PHP: WP: Turn on error reporting
<?php
// add this before any other code on a page, errors will print at bottom
// via http://stackoverflow.com/questions/1018935/get-and-wordpress
error_reporting(E_ALL);
ini_set('display_errors', true);
?>
@astockwell-ps
astockwell-ps / CSS iOS OrientationZoom Solved
Created April 27, 2012 00:27
CSS: iOS Orientation/Zoom Solved
/* Via http://css-tricks.com/forums/discussion/13461/landscape-orientation/p1 */
<meta name="viewport" content="width=device-width; initial-scale=1" />
<!-- Add "maximum-scale=1" to fix the weird iOS auto-zoom bug on orientation changes. -->
@media (max-device-width: 480px) and (orientation: landscape) {}
@astockwell-ps
astockwell-ps / PHP: Custom WordPress login logo
Created April 27, 2012 00:23
PHP: Customize WordPress login logo without a plugin