Skip to content

Instantly share code, notes, and snippets.

@manmar
manmar / wp_media_upload.js
Created June 23, 2015 08:35
Use WordPress media uploader from custom meta fields or widgets
jQuery(document).ready(function($) {
var imageFrame;
$(document).on("click", ".upload_image_button", function() {
event.preventDefault();
var options, attachment;
@gerbenvandijk
gerbenvandijk / Mark parent navigation active when on custom post type single page
Last active November 3, 2025 20:30
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
@mikeschinkel
mikeschinkel / wp-post-counts-for-user-by-post-type.php
Created October 24, 2010 07:06
Adds Post Counts by Post Type per User in the User List withing WordPress' Admin console (URL path => /wp-admin/users.php)
<?php
/*
Adds Post Counts by Post Type per User in the User List withing WordPress' Admin console (URL path => /wp-admin/users.php)
Written for: http://wordpress.stackexchange.com/questions/3233/showing-users-post-counts-by-custom-post-type-in-the-admins-user-list
By: Mike Schinkel (http://mikeschinkel.com)
Date: 24 October 2010
*/