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
@felipelavinz
felipelavinz / get_by_name.php
Created November 24, 2009 18:24
Get stuff by name (WordPress)
<?php
/**
* Get stuff ID by nicename
* @param $nicename string The nicename (i.e: post-slug) to get the ID for
* @param $type string The table that will be queried: posts (default), term, users
* @return integer The ID for the requested object, false if nothing found
*/
function get_by_name($nicename, $type="posts"){
global $wpdb;
if ( empty($type) OR $type === 'post'){
@elg0nz
elg0nz / Rss.php
Created February 1, 2010 01:49
Rss Fetching with wordpress' fetch_feed
<?php include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_feed('http://twitter.com/statuses/user_timeline/13436616.rss');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
@seedprod
seedprod / wp-blog-defaults.php
Created April 18, 2010 19:01
WP Blog Defaults
<?php
/******************************************************************************************************************
Plugin Name: cets_blog_defaults
Plugin URI:
Description: WordPressMU plugin for site admin to set defaults for new blogs.
Version: 1.2.3
@livingston
livingston / getLocation.html
Created April 28, 2010 12:40
HTML5 Geolocation with Fallback to Google Ajax API
<!-- HTML5 Geolocation with Fallback to Google Ajax API
-- http://marcgrabanski.com/article/html5-geolocation-fallback-google-ajax-api
-->
<script src="http://www.google.com/jsapi?key=YOUR_API_KEY" type='text/javascript'></script>
<script type='text/javascript'>
var myLocation; // global variable to store lat/lng
if (navigator && navigator.geolocation) {
// HTML5 GeoLocation
function getLocation(position) {
@livingston
livingston / gist:383512
Created April 29, 2010 12:14
Cleanup Wordpress Header & use Google Hosted jQuery
<?php
/* Cleanup Wordpress Header & use Google Hosted jQuery */
function cleanUp() {
function restatement_scripts_unversion($src) {
if( strpos($src,'ajax.googleapis.com') )
$src=remove_query_arg('ver', $src);
return $src;
}
@danielbachhuber
danielbachhuber / Show author metadata if available
Created May 16, 2010 03:58
Shows WordPress author metadata if available
<?php $author = get_post_meta($post->ID, 'author', true);
if ($author) { echo $author; } else { the_author(); } ?>
@thefuxia
thefuxia / Wordpress-feed-desc-fulltext.php
Created July 22, 2010 10:18
Print full text in feed description
<?php
add_filter('the_excerpt_rss', 'my_fulltext_desc');
function my_fulltext_desc($excerpt)
{
if ( ! is_feed() )
{
return $excerpt;
}
return apply_filters('the_content', get_the_content() );
@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 / 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)