Skip to content

Instantly share code, notes, and snippets.

View roose's full-sized avatar
🐢
Looking for a job

roose roose

🐢
Looking for a job
View GitHub Profile
@scribu
scribu / gist:856587
Created March 5, 2011 18:34
'product' post type + 'color' taxonomy
<?php
// Register the post type and taxonomy
function init_product_cpt() {
register_post_type( 'product', array(
'public' => true,
'label' => __( 'Products', 'my-plugin' )
) );
register_taxonomy( 'color', 'product', array(
@jaredwilli
jaredwilli / Attachment Uploader Metabox
Created February 10, 2011 07:03
Need to save or refresh post after adding new input group to make the ajax upload init
<?php
/**
* Name: Attachments Metabox Uploader
* Author: Jared Williams - http://new2wp.com
* Description: This is for adding a custom metabox to post types which enables you to add/remove
* post attachments that you can upload and enter the meta information for right on the edit page.
* Version: 0.1.0
*
* Notes: In order to add this to a post type you need to find the word 'product' and replace it with * whatever the post type is you want to use it on.
*/
@jaredwilli
jaredwilli / Recent Custom Posts Widget
Created February 2, 2011 06:27
Extends the WordPress Recent Posts widget to support custom post types
<?php
/*
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', home_url() . '/' ) );
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', site_url() . '/' ) );
define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
*/
define( 'WPH_FUNC_PATH', get_template_directory() . '/functions' );
define( 'WPH_FUNC_URL', get_bloginfo('template_directory' ).'/functions' );
<?php
/**
* Name: Attachments Metabox Uploader
* Author: Jared Williams - http://new2wp.com
* Description: This is for adding a custom metabox to post types which enables you to add/remove
* post attachments that you can upload and enter the meta information for right on the edit page.
* Version: 0.1.0
*
* @usage: In order to add this to a post type you need to find the word 'product' and replace
* it with whatever the post type is you want to use it on.
<?php
/**
* Custom Metabox for uploading post image attachments
* Created by Jared Williams - http://new2wp.com
*/
add_action( 'admin_init', 'add_attachment' );
add_action( 'save_post', 'update_attachment' );
add_action( 'post_edit_form_tag', 'form_multipart_encoding' );
//add_action( 'manage_posts_custom_column', 'product_custom_columns' );
//add_filter( 'manage_edit-product_columns', 'product_edit_columns' );
@GuilhermeBarile
GuilhermeBarile / Facebook like button
Last active December 5, 2017 08:01
Wordpress code snippets
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink()) ?>&amp;layout=button_count&amp;show_faces=false&amp;width=90&amp;action=like&amp;colorscheme=light&amp;height=21" width="90" height="21" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
@najamsk
najamsk / loop.php
Created January 21, 2011 09:53
wordpress code snippets i use alot
<?php $epaged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$temp = $wp_query;
$wp_query = null;
?>
<?php $wp_query = new WP_Query('category_name=portfolio&tag=web&showposts=5&paged=' . $epaged);?>
<?php if ($wp_query->have_posts()) : ?>
<section class="itemBlocks">
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article class="iBlock">
<time datetime="<?php the_time('Y-m-d') ?>" class="fs-14" pubdate><?php the_time('F jS, Y') ?></time>
@mikeschinkel
mikeschinkel / admin-menu-challenge.php
Created January 15, 2011 05:03
The Great WordPress Admin Menu Challenge of Jan 2011
<?php
/*
Plugin Name: The Great WordPress Admin Menu Challenge of Jan 2011
Description: <em>"The Great WordPress Admin Menu Challenge of Jan 2011"</em> was inspired by the WordPress team's apparent lack of understanding of the problems addressed by trac tickets <a href="http://core.trac.wordpress.org/ticket/16048">#16048</a> and <a href="http://core.trac.wordpress.org/ticket/16050">#16050</a> <em>(See also: <a href="http://core.trac.wordpress.org/ticket/16204">#16204</a>)</em> and suggestion that the <a href="http://wordpress.org/extend/plugins/admin-menu-editor/>Admin Menu Editor</a> plugin handles the use-cases that the tickets address. Debate spilled over onto Twitter with participation from <a href="http://twitter.com/nacin">@nacin</a>, <a href="http://twitter.com/aaronjorbin">@aaronjorbin</a>, <a href="http://twitter.com/petemall">@petemall</a>, <a href="http://twitter.com/westi">@westi</a>, <a href="http://twitter.com/janeforshort">@janeforshort</a>, <a href="http://twitter.com/PatchesWelcome">@PatchesW
@mfields
mfields / mfields-taxonomy-map.php
Created January 8, 2011 01:11
WordPress Taxonomy Map Plugin
<?php
/*
Plugin Name: Taxonomy Map
Plugin URI: http://wordpress.mfields.org/plugins/taxonomy-images/
Description: Use a hierarchical taxonomy system to display Goole map.
Version: 0.1
Author: Michael Fields
Author URI: http://wordpress.mfields.org/
License: GPLv2
@jhaus
jhaus / google-weather-api.php
Created January 4, 2011 23:05
Prints current + 3 day weather forecast - via: googleapihelp.com (slightly modified)
<?php
$weather_loc = 10001;
function getWeather( $weather_loc ) {
// weather data url, location based
$requestAddress = 'http://www.google.com/ig/api?weather=$weather_loc&hl=en';
// Parse XML
$xml_str = file_get_contents($requestAddress,0);