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
@thefuxia
thefuxia / post-cats-to-css-classes.php
Created July 24, 2010 23:26
Converts post categories into CSS classes
<?php
function categories_to_classes()
{
$out = '';
$cats = get_the_category();
foreach ( $cats as $cat_object )
{
$out .= $cat_object->slug . ' ';
}
<?php
/*
Description: Adds a taxonomy filter in the admin list page for a custom post type.
Written for: http://wordpress.stackexchange.com/posts/582/
By: Mike Schinkel - http://mikeschinkel.com/custom-workpress-plugins
Instructions: Put this code in your theme's functions.php file or inside your own plugin. Edit to suite your post types and taxonomies. Hope this helps...
*/
add_filter('manage_listing_posts_columns', 'add_businesses_column_to_listing_list');
function add_businesses_column_to_listing_list( $posts_columns ) {
if (!isset($posts_columns['author'])) {
@scribu
scribu / category-custom-fields.php
Created October 8, 2010 13:24
Category Custom Fields
<?php
/*
Plugin Name: Category Custom Fields
Author: scribu
*/
class Category_Custom_Fields {
function init() {
@jbynum
jbynum / Paginate Custom Posts
Created October 22, 2010 21:38
how to paginate custom post type in wordpress
<?php
$docs = get_posts('numberposts=-1&post_type=page&post_parent=36&orderby=title&order=ASC');
$faculty = array();
foreach ($docs as $doc) {
array_push($faculty, $doc->ID);
}
$currentElement = array_search($post->ID, $faculty);
$next = isset( $faculty[$currentElement+1] ) ? $faculty[$currentElement+1] : null;
$prev = isset($faculty[$currentElement-1]) ? $faculty[$currentElement-1] : null;
if ( !is_null($prev) ) {
@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
*/
@mikeschinkel
mikeschinkel / posts-by-category-with-price.php
Created October 26, 2010 05:58
Query for a list of WordPress posts by category, but only those with a postmeta->meta_key='Price' that's >0 and NOT NULL.
<?php
/*
posts-by-category-with-price.php
Query for a list of WordPress posts by category,
but only those with a postmeta->meta_key='Price' that's >0 and NOT NULL.
Author: Mike Schinkel (http://mikeschinkel.com)
@mikeschinkel
mikeschinkel / posts-by-taxonomy.php
Created November 6, 2010 01:50
Class to extended WordPress' 3.0.x WP_Query to allow querying for all terms in a taxonomy.
<?php
/*
PostsByTaxonomy class that extends WP_Query and filters to includes all posts that have any term of a taxonomy.
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See:
@mikeschinkel
mikeschinkel / posts-ordered-by-meta.php
Created November 6, 2010 09:05
Class to extended WordPress' 3.0.x WP_Query to allow sorting by a meta_key.
<?php
/*
PostsOrderedByMetaQuery class that extends WP_Query and sorts posts meta_key
Author: Mike Schinkel (http://mikeschinkel.com)
This example works, just drop into the root of your website and call directly.
Use the class in your plugins or themes.
See: http://stackoverflow.com/questions/4111255/how-to-sort-a-query-posts-function-by-custom-field-while-limiting-posts-by-ano
@felipelavinz
felipelavinz / functions.php
Created November 9, 2010 20:38
A basic WordPress functions.php as starting point for theme development
<?php
/* Register WordPress theme settings ******************************************/
/* Navigation menus -----------------*/
register_nav_menus( array(
'primary' => 'Principal'
));
/* Images ---------------------------*/
add_theme_support( 'post-thumbnails' );
/* Sidebars -------------------------*/
@felipelavinz
felipelavinz / WP_Widget_update_array.php
Created November 17, 2010 19:35
Save array data on WordPress Widgets
<?php
/**
* To be used on a WordPress Widget object
* Fields named as '_foo_bar' will become $new_instance['foo']['bar'] = $val
* Fields named as '_lorem_ipsum_dolor' become $new_instance['lorem']['ipsum']['dolor'] = $val
**/
function update( $new_instance, $old_instance ) {
foreach ( $new_instance as $key => $val ) {