Skip to content

Instantly share code, notes, and snippets.

NOTES

1. When initial code didn't work, I installed Debug Bar plugin and then not-yet-released Debug Bar Rewrite Rules plugin by Oleg Butuzov (who mailed it to me).

With the two plugins installed, click Debug link in admin bar, and in the popover select the Rewrite Rules tab. Now you'll see a list of all the rewrite rules in place on your site.

By comparing the regex, rewrite rules used for similar stuff (e.g. category archives, category archive pagination, category feeds, etc.) I was able to frame my own rules properly.

2. Resources

@aahan
aahan / file.php
Last active December 28, 2015 03:09
<?php
/*
* Get category from query_var of current page
*
* http://codex.wordpress.org/Function_Reference/get_query_var
* http://codex.wordpress.org/Function_Reference/get_term
* http://codex.wordpress.org/Function_Reference/get_term_by
* http://codex.wordpress.org/Function_Reference/get_category_by_path
* http://codex.wordpress.org/Function_Reference/get_category_by_slug
* http://codex.wordpress.org/Function_Reference/get_the_category
@aahan
aahan / WordPress Custom Global Variables.md
Last active March 28, 2024 19:26
Creating and using custom global variables in wordpress.

First create global variables (in functions.php or as a mu-plugin):

<?php

/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {
@aahan
aahan / wp-seo-filters.php
Created November 13, 2013 13:36
WordPress SEO by Yoast filters
<?php
// Remove Canonical Link Added By Yoast WordPress SEO Plugin
function at_remove_dup_canonical_link() {
return false;
}
add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' );
function wpseo_attachment_canonical_parent( $canonical ) {
@aahan
aahan / style.css
Created December 1, 2013 15:01
Crop image using CSS
/*
* Crop image using CSS
*/
#top-stories figure,
#latest-stories figure {
display: block;
overflow: hidden;
width: 81px;
}
@aahan
aahan / Disqus lazy load.md
Last active December 30, 2015 12:09
Lazy loading Disqus comments (i.e. loading on scroll) can be done with these JavaScript plugins.
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#359",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
@aahan
aahan / ps.md
Created July 16, 2014 19:33
Windows 7 File Properties: Get 'date created' up to seconds using PowerShell

Open PowerShell: Start > All Programs > Accessories > Windows PowerShell > Windows PowerShell

To get Date Created, run commands:

$file = Get-Item "D:\My folder\my-file.md"
$file.CreationTime

The output will look like this (in system's local time):

Wednesday, July 16, 2014 16:24:00