Skip to content

Instantly share code, notes, and snippets.

Alex King alexkingorg

Block or report user

Report or block alexkingorg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
alexkingorg / wp-page-tags.php
Created Feb 6, 2014
Enable tags for pages (old code archive) for WordPress.
View wp-page-tags.php
Plugin Name: CF Page Tags
Plugin URI:
Description: Add the tags form to pages in WP.
Author: Crowd Favorite
Author URI:
Version: 1.0
View wpdb-implode.php
$results = $wpdb->get_results(
SELECT ID, post_title, post_name, post_parent
FROM $wpdb->posts
WHERE post_parent IN (".implode(',', array_map('intval', $post_ids)).")
View wordpress-template.php
* The main template file.
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
* Learn more:
alexkingorg / wp-customer-posts-per-page.php
Created Jan 12, 2014
Customize posts-per-page based on some condition.
View wp-customer-posts-per-page.php
// add filter for front-end requests
if (!is_admin() && !is_feed()) {
add_filter('parse_request', 'my_add_posts_per_page');
// add our condition-checking filter
function my_add_posts_per_page() {
add_filter('pre_get_posts', 'my_posts_per_page');
alexkingorg / register-all-postmeta.php
Created Jan 7, 2014
Register all WP postmeta keys using the [CF Revision Manager](
View register-all-postmeta.php
global $wpdb;
$keys = $wpdb->get_col("
FROM $wpdb->postmeta
foreach ($keys as $key) {
alexkingorg / spam-comment-script.txt
Created Dec 22, 2013
A spam comment script with replacement clauses intact - accidentally submitted in it's entirety to my site.
View spam-comment-script.txt
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch} your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any? {Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe. Thanks.|
{It is|It's} {appropriate|perfect|the best} time to make some plans for the future and {it is|i
alexkingorg / column-view-default-hack.js
Created Dec 11, 2013
Replace default link with Column View
View column-view-default-hack.js
jQuery(function($) {
$('#menu-pages > a[href="edit.php?post_type=page"]')
.attr('href', 'edit.php?post_type=page&page=cf-admin-column-view-page');
alexkingorg / sass-selectors.scss
Last active Jun 3, 2016
Use SASS variables for selectors.
View sass-selectors.scss
// Vars - note the quotes around comma separated selectors
$a-tags: 'a, a:active, a:hover, a:visited';
$a-tags-hover: 'a:active, a:hover';
// Usage
#{$a-tags} {
color: red;
font-size: 1em;
text-decoration: none;
alexkingorg / .gitconfig
Last active Dec 21, 2015
Some gitconfig aliases. #git
View .gitconfig
up = "pull --rebase"
pullmerge = "pull --no-rebase"
subup = "!f() { git submodule sync; git submodule update --init --recursive; }; f"
subreset = "submodule foreach 'git reset --hard HEAD'"
who = shortlog -s --
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
info = remote -v
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..@{u})
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' @{u}..)
alexkingorg / github-activity-feed.php
Last active Dec 19, 2015
Pull GitHub activity feed into WordPress and output the items of interest.
View github-activity-feed.php
$feed = fetch_feed('');
// some activity isn't interesting enough to output
$ignore_types = array(
You can’t perform that action at this time.