Search result for 'insert wordpress custom menu'
(0.0495820045471 seconds)

coryschadt/Wordpress - Remove stuff from Dashboard ( PHP)

add_action( 'admin_menu', 'custom_admin_menu' );

function custom_admin_menu() 
{
global $menu;
/*
echo '<pre>';
var_dump($menu); // use this to identify the key for the menu item you want to remove
echo '</pre>';
*/
unset( $menu[5] ); //key 5 is posts
unset( $menu[15] ); //key 15 is links
unset( $menu[25] ); //key 25 is comments
if ( !current_user_can('manage_options') ) { unset( $menu[75] ); } //key 75 is tools ... but only for non super admins
}

shufflepath/WordPress Custom Post Type &amp; Taxonomy ( PHP)

function customPostType($posttype, $name, $tax, $supports) {
�2.�
	$labels = array(
�3.�
		'name' => _x($name, 'post type general name'),
�4.�
		'singular_name' => _x($name, 'post type singular name'),
�5.�
		'add_new' => _x('Add New', strtolower($name) . ' item'),
�6.�
		'add_new_item' => __('Add New ' . $name),
�7.�
		'edit_item' => __('Edit ' . $name),
�8.�
		'new_item' => __('New ' . $name),
�9.�
		'view_item' => __('View ' . $name),
�10.�
		'search_items' => __('Search ' . $name),
�11.�
		'not_found' =>  __('Nothing found'),
�12.�
		'not_found_in_trash' => __('Nothing found in Trash'),
�13.�
		'parent_item_colon' => ''
�14.�
	);
�15.�
 
�16.�
	$rewrite = false;
�17.�
	if($posttype=='collections' || $posttype=='agency') $rewrite = array('with_front'=>false);
�18.�
	$args = array(
�19.�
		'labels' => $labels,
�20.�
		'public' => true,
�21.�
		'publicly_queryable' => true,
�22.�
		'show_ui' => true,
�23.�
		'query_var' => true,
�24.�
		//'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
�25.�
		'rewrite' => $rewrite,
�26.�
		'capability_type' => 'page',
�27.�
		'hierarchical' => true,
�28.�
		'menu_position' => null,
�29.�
		'supports' => $supports
�30.�
	  );
�31.�
 
�32.�
	register_post_type($posttype,$args);
�33.�
}
�34.�
 
�35.�
function customTaxonomy($name, $query_var, $slug, $label, $posttype, $singular) {
�36.�
	register_taxonomy($name, $posttype, array(	"hierarchical" => true, 
�37.�
							"label" => $label, 
�38.�
							"singular_label" => $singular, 
�39.�
							"query_var" => $query_var, 
�40.�
							"rewrite" => false
�41.�
						));
�42.�
}

FXDB/Change WordPress 3.3 Howdy text in the Admin Bar ( PHP)

add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 );

function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );

if ( 0 != $user_id ) {
/* Add the "My Account" menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Welcome, %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';

$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
),
) );

}
}

Normally it says Howdy, Username. This shows how to change the Howdy text and replace it with Welcome. Add this snippet to Functions.php or create it as a site plugin.

gustao/Registrar novo tipo de Post ( PHP)

// REGISTRANDO TIPO DE POST: CONCURSO
function post_type_concurso() {
  $labels = array(
    'name' => _x('Você na foto', 'post type general name'),
    'singular_name' => _x('Você na foto', 'post type singular name'),
    'add_new' => _x('Adicionar Novo', 'participante'),
    'add_new_item' => __('Adicionar Novo Participante'),
    'edit_item' => __('Editar Participante'),
    'new_item' => __('Novo Participante'),
    'all_items' => __('Todos os Participantes'),
    'view_item' => __('Ver Participante'),
    'search_items' => __('Pesquisar Participante'),
    'not_found' =>  __('Nenhum participante encontrado'),
    'not_found_in_trash' => __('Nenhum participante encontrado na Lixeira'),
    'parent_item_colon' => '',
    'menu_name' => __('Você na foto')
  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'voce-na-foto/participante'),
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => 5,
    'taxonomies' => array('post_tag'),
    'supports' => array( 'title', 'editor', 'custom-fields' )
  );
  register_post_type('concurso',$args);
}
add_action( 'init', 'post_type_concurso' );

baires/Automatically Create A Page On Theme Activation ( PHP)

if ($_GET['activated']){

	$new_page_title = 'This is the page title';
	$new_page_content = 'This is the page content';
	$new_page_template = ''; //ex. template-custom.php. Leave blank if you don't want a custom page template.

	//don't change the code bellow, unless you know what you're doing

	$page_check = get_page_by_title($new_page_title);
	$new_page = array(
		'post_type' => 'page',
		'post_title' => $new_page_title,
		'post_content' => $new_page_content,
		'post_status' => 'publish',
		'post_author' => 1,
	);
	if(!isset($page_check->ID)){
		$new_page_id = wp_insert_post($new_page);
		if(!empty($new_page_template)){
			update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
		}
	}

}

tomdowning/WP all query options ( PHP)

offset - start from post number
orderby - order by id,author,title,date,modified,parent,rand,menu_order,meta_value
order - ASC,DESC
author - show posts from one author, use author id or name 

cat (int) - use category id.
category_name (string) - use category slug (NOT name).
category__and (array) - use category id.
category__in (array) - use category id.
category__not_in (array) - use category id.

tag (string) - use tag slug.
tag_id (int) - use tag id.
tag__and (array) - use tag ids.
tag__in (array) - use tag ids.
tag__not_in (array) - use tag ids.
tag_slug__and (array) - use tag slugs.
tag_slug__in (array) - use tag slugs.

tax_query (array) - use taxonomy parameters (available with Version 3.1).
taxonomy (string) - Taxonomy.
field (string) - Select taxonomy term by ('id' or 'slug')
terms (int/string/array) - Taxonomy term(s).
operator (string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.

p (int) - use post id.
name (string) - use post slug.
page_id (int) - use page id.
pagename (string) - use page slug.
post_parent (int) - use page id. Return just the child Pages.
post__in (array) - use post ids. Specify posts to retrieve.
post__not_in (array) - use post ids. Specify post NOT to retrieve.

post_type (string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
	'post' - a post.
	'page' - a page.
	'revision' - a revision.
	'attachment' - an attachment. The default WP_Query sets 'post_status'=>'published', but attachments default to 	'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
	'any' - retrieves any type except revisions and types with 'exclude_from_search' set to true.

post_status (string / array) - use post status. Retrieves posts by Post Status, default value is 'publish'.
	'publish' - a published post or page.
	'pending' - post is pending review.
	'draft' - a post in draft status.
	'auto-draft' - a newly created post, with no content.
	'future' - a post to publish in the future.
	'private' - not visible to users who are not logged in.
	'inherit' - a revision. see get_children.
	'trash' - post is in trashbin (available with Version 2.9).
	'any' - retrieves any status except those from post types with 'exclude_from_search' set to true.

meta_key (string) - Custom field key.
meta_value (string) - Custom field value.
meta_compare (string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or '<='. Default value is '='.

meta_query (array) - Custom field parameters (available with Version 3.1).
key (string) - Custom field key.
value (string|array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
compare (string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
type (string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.

blueocto/Wordpress Stylesheet ( CSS)

/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: the WordPress team
Version: 1.0 
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)

License:
License URI:

General comments (optional).
*/

In addition to CSS style information for your theme, style.css provides details about the Theme in the form of comments. The stylesheet must provide details about the Theme in the form of comments. No two Themes are allowed to have the same details listed in their comment headers, as this will lead to problems in the Theme selection dialog. If you make your own Theme by copying an existing one, make sure you change this information first.

The following is an example of the first few lines of the stylesheet, called the stylesheet header, for the Theme "Twenty Ten":

thesmu/WordPress, IIS, Permalinks and index.php | Richard Shepherd ( PHP)

Here’s the problem:

You need to install WordPress on a Windows machine running IIS. I’d never normally do this, but sometimes you just don’t have a choice.

There are plenty of links out there about how to do this, and the one I referred to most was How To Install WordPress on IIS 6.0. It is, more or less, straightforward.

However, there’s an issue with IIS and permalinks.The issue is that if you want to take advantage of the WordPress pretty permalinks, you have to suffer a folder in the path called ‘index.php’. So, instead of the rather lovely:

http://www.yourblog.com/yourcategories/the-best-post-in-the-world/

you have to grit your teeth and accept:

http://www.yourblog.com/index.php/yourcategories/the-best-post-in-the-world/

I don’t know why, I really don’t. I’m not that smart. But I did work out how to fix it. It’s easy enough, but you have to put a couple of rules in the ISAPI ReWrite Engine to deal with the quirks.

First we need to head into our WordPress admin tool, and go to Settings > Permalinks. There, you’ll see the craft insertion of /index.php/ in the links. We need to create a custom permalink and delete the index.php bit. Just like this…



Now save that off and head over to your .htaccess file – we need to weave some magic!

At the bottom of this post is the whole file, but the two lines I particularly want to point out are:

1
2
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteRule ^/(.*)/$ /index.php/$1 [NC]
The second line works the juju. It takes the URL from the browser, shoves an /index.php/ into it, and displays the contents. For more on how and why this works, check out http://www.workingwith.me.uk/articles/scripting/mod_rewrite for the basics.

Now the first line is really important, because it tells the server not to do this if we’re in the admin section. If we remove this line, there are all kinds of problems reaching /wp-admin/index.php. Trust me.

I have two other lines in the following code which get rid of index.php from URLS, which stops the google duplicate content issue. They’re always worth having.

Finally, make sure that wherever your site is hosted, that the correct permissions are set on the wp-admin and wp-content directories and their sub-directories. You must have read/write/modify permissions set for internal user accounts.

If you implement these small tweaks, then your WordPress IIS install should work like a charm.

Good luck!

Here’s the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -------------------------------------------------------------------------
# Kickstart the Rewrite Engine and set initial options
# -------------------------------------------------------------------------
 
RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase
 
# -------------------------------------------------------------------------
# WORDPRESS, WINDOWS & ISAPI DOCUMENTATION
# -------------------------------------------------------------------------
# These are the WordPress redirects we need in place for a Windows Server
# running PHP & MySQL
# We had some issues configuring ISAPI with WordPress and so here are the
# solutions in case we need them again!!
 
# -------------------------------------------------------------------------
# PERMISSIONS SETTINGS
# -------------------------------------------------------------------------
# The following folders:
# wp-admin
# wp-content
# MUST HAVE read/write/modify permissions set for internal user accounts
 
# -------------------------------------------------------------------------
# ESSENTIAL WORDPRESS REWRITES
# -------------------------------------------------------------------------
 
# Redirects 'www.yourblogsite.com/index.php' to 'www.yourblogsite.com/'
 
RewriteRule ^/index.php$ / [NC,P,R=301]
 
# Rewrite 'www.yourblogsite.com/anything/' to 'www.yourblogsite.com/index.php/anything/'
# NB. The user does not see this rewrite.
# Must also go into WordPress > Settings > Permalinks and select 'custom'
# and then REMOVE 'index.php' from the custom URL it generates
 
# The first line is a condition so it doesn't apply the rule to the wp-admin part of the site
 
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteRule ^/(.*)/$ /index.php/$1 [NC]
 
# Finally, redirect 'www.yourblogsite.com/anything/anything/index.php'
# to 'www.yourblogsite.com/anything/anything/'
 
RewriteRule ^/(.*)/index.php$ /$1/ [NC,P,R=301]
 
# -------------------------------------------------------------------------
# END OF ESSENTIAL REWRITES
# -----------------------------

WordPress, IIS, Permalinks and index.php | Richard Shepherd

sdellow/Wordpress Code Snippets ( HTML)

<h2>Automatically Add Twitter and Facebook Buttons to Your Posts</h2><p>This snippet will add Twitter and Facebook buttons to the bottom of all your posts. All you have to do is paste the code below into your <code>functions.php</code> file:</p><pre class="brush: php; title: ;" title=""> 
function share_this($content){
    if(!is_feed() &amp;amp;&amp;amp; !is_home()) {
        $content .= '&amp;lt;div class=&amp;quot;share-this&amp;quot;&amp;gt;
                    &amp;lt;a href=&amp;quot;http://twitter.com/share&amp;quot;
class=&amp;quot;twitter-share-button&amp;quot;
data-count=&amp;quot;horizontal&amp;quot;&amp;gt;Tweet&amp;lt;/a&amp;gt;
                    &amp;lt;script type=&amp;quot;text/javascript&amp;quot;
src=&amp;quot;http://platform.twitter.com/widgets.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
                    &amp;lt;div class=&amp;quot;facebook-share-button&amp;quot;&amp;gt;
                        &amp;lt;iframe
src=&amp;quot;http://www.facebook.com/plugins/like.php?href='.
urlencode(get_permalink($post-&amp;gt;ID))
.'&amp;amp;amp;layout=button_count&amp;amp;amp;show_faces=false&amp;amp;amp;width=200&amp;amp;amp;action=like&amp;amp;amp;colorscheme=light&amp;amp;amp;height=21&amp;quot;
scrolling=&amp;quot;no&amp;quot; frameborder=&amp;quot;0&amp;quot; style=&amp;quot;border:none;
overflow:hidden; width:200px; height:21px;&amp;quot;
allowTransparency=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;';
    }
    return $content;
}
add_action('the_content', 'share_this');
</pre><p><a href="http://www.wprecipes.com/automatically-add-twitter-and-facebook-buttons-to-your-posts" class="button-med">Source &amp;rarr;</a></p><h2>Track Post View Amount by Using Post Meta</h2><p>For a simple way to keep track of the number of post views, paste this snippet into the <code>functions.php</code>, and then follow steps 1 and 2.</p><pre class="brush: php; title: ;" title=""> 
function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return &amp;quot;0 View&amp;quot;;
    }
    return $count.' Views';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
</pre><p>Step 1: Paste the code below within the <code>single.php</code> within the loop:</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php
          setPostViews(get_the_ID());
?&amp;gt;
</pre><p>Step 2: Paste the snippet below anywhere within the template where you would like to display the number of views:</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php
          echo getPostViews(get_the_ID());
?&amp;gt;
</pre><p><a href="http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/" class="button-med">Source &amp;rarr;</a></p><h2>Track Post View Amount by Using Post Meta</h2><p>This snippet will create a list of your most popular posts based on page views. Please note that this will only work if you have already implemented the &amp;#8216;Track Post View Amount by Using Post Meta&amp;#8217; from above.<br /> Place this snippet just before the loop within the <code>index.php</code> template and WordPress will use the post views to order your posts from highest to lowest.</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?
query_posts('meta_key=post_views_count&amp;amp;orderby=post_views_count&amp;amp;order=DESC');
?&amp;gt;
</pre><p><a href="http://wpsnipp.com/index.php/loop/most-popular-posts-using-views-post-meta/" class="button-med">Source &amp;rarr;</a></p><h2>Breadcrumbs Without a Plugin</h2><p>Breadcrumbs can be a useful navigation technique that offers link to the previous page the user navigated through to arrive at the current post/page. There are plugins you could use, but the code snippet below could be an easier solution.</p><p>Paste this code into your <code>functions.php</code> file.</p><pre class="brush: php; title: ;" title=""> 
function the_breadcrumb() {
echo '&amp;lt;ul id=&amp;quot;crumbs&amp;quot;&amp;gt;';
if (!is_home()) {
echo '&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;';
echo get_option('home');
echo '&amp;quot;&amp;gt;';
echo 'Home';
echo &amp;quot;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&amp;quot;;
if (is_category() || is_single()) {
echo '&amp;lt;li&amp;gt;';
the_category(' &amp;lt;/li&amp;gt;&amp;lt;li&amp;gt; ');
if (is_single()) {
echo &amp;quot;&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;&amp;quot;;
the_title();
echo '&amp;lt;/li&amp;gt;';
}
} elseif (is_page()) {
echo '&amp;lt;li&amp;gt;';
echo the_title();
echo '&amp;lt;/li&amp;gt;';
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo&amp;quot;&amp;lt;li&amp;gt;Archive for &amp;quot;; the_time('F jS, Y'); echo'&amp;lt;/li&amp;gt;';}
elseif (is_month()) {echo&amp;quot;&amp;lt;li&amp;gt;Archive for &amp;quot;; the_time('F, Y'); echo'&amp;lt;/li&amp;gt;';}
elseif (is_year()) {echo&amp;quot;&amp;lt;li&amp;gt;Archive for &amp;quot;; the_time('Y'); echo'&amp;lt;/li&amp;gt;';}
elseif (is_author()) {echo&amp;quot;&amp;lt;li&amp;gt;Author Archive&amp;quot;; echo'&amp;lt;/li&amp;gt;';}
elseif (isset($_GET['paged']) &amp;amp;&amp;amp; !empty($_GET['paged'])) {echo &amp;quot;&amp;lt;li&amp;gt;Blog Archives&amp;quot;; echo'&amp;lt;/li&amp;gt;';}
elseif (is_search()) {echo&amp;quot;&amp;lt;li&amp;gt;Search Results&amp;quot;; echo'&amp;lt;/li&amp;gt;';}
echo '&amp;lt;/ul&amp;gt;';
}</pre><p>Then paste the calling code below, wherever you would like the breadcrumbs to appear (typically above the title tag).</p><pre class="brush: php; title: ;" title="">&amp;lt;?php the_breadcrumb(); ?&amp;gt;</pre><p><a href="http://wp-snippets.com/breadcrumbs-without-plugin/" class="button-med">Source &amp;rarr;</a></p><h2>Display the Number of Facebook Fans</h2><p>Facebook is a must site for sharing your blogs articles. Here is a method for showing your visitors the total number of Facebook &amp;#8216;Likes&amp;#8217; your blog currently has.</p><p>To use this code all you have to do is replace the <strong>YOUR PAGE-ID</strong> with your own Facebook page id.</p><pre class="brush: php; title: ;" title="">&amp;lt;?php
$page_id = &amp;quot;YOUR PAGE-ID&amp;quot;;
$xml = @simplexml_load_file(&amp;quot;http://api.facebook.com/restserver.php?method=facebook.fql.query&amp;amp;query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=&amp;quot;.$page_id.&amp;quot;&amp;quot;) or die (&amp;quot;a lot&amp;quot;);
$fans = $xml-&amp;gt;page-&amp;gt;fan_count;
echo $fans;
?&amp;gt;</pre><p><a href="http://wp-snippets.com/display-number-facebook-fans/" class="button-med">Source &amp;rarr;</a></p><h2>Display an External RSS Feed</h2><p>This snippet will fetch the latest entries of any specified feed url.</p><pre class="brush: php; title: ;" title="">&amp;lt;?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://wpforums.com/external.php?type=RSS2', 5); ?&amp;gt;</pre><p>This code takes the rss.php file that is built into WordPress (used for widgets). It is set to display the most recent 5 posts from the RSS feed &amp;#8216;http://example.com/external.php?type=RSS2&amp;#8242;.</p><p><a href="http://wphacks.com/how-to-adding-an-external-rss-feed-to-your-wordpress-blog/" class="button-med">Source &amp;rarr;</a></p><h2>WP Shortcode to Display External Files</h2><p>If you are looking for a quick way to automatically include external page content within your post, this snippet will create a shortcode allowing you to do it.</p><p>Paste this code into your themes <code>functions.php</code> file:</p><pre class="brush: php; title: ;" title=""> 
function show_file_func( $atts ) {
  extract( shortcode_atts( array(
    'file' =&amp;gt; ''
  ), $atts ) );
 
  if ($file!='')
    return @file_get_contents($file);
}
 
add_shortcode( 'show_file', 'show_file_func' );
</pre><p>And then post this shortcode, editing the URL, into your post or page.</p><pre class="brush: php; title: ;" title=""> 
[show_file file=&amp;quot;http://speckyboy.com/2010/12/09/20-plugin-replacing-tutorials-tips-snippets-and-solutions-for-wordpress/&amp;quot;]
</pre><p><a href="http://www.prelovac.com/vladimir/wordpress-shortcode-snippet-to-display-external-files" class="button-med">Source &amp;rarr;</a></p><h2>Create Custom Widgets</h2><p><img src="http://speckyboy.com/wp-content/uploads/2011/03/wp_snippet_06.jpg" alt="Create Custom Widgets"><br /> Wordpress provides many widgets, but if you want to create custom widgets tailored to your blog, then this snippet may help you.</p><p>Paste the code below into your <code>functions.php</code> file.</p><pre class="brush: php; title: ;" title="">    class My_Widget extends WP_Widget {
        function My_Widget() {
            parent::WP_Widget(false, 'Our Test Widget');
        }
    function form($instance) {
            // outputs the options form on admin
        }
    function update($new_instance, $old_instance) {
            // processes widget options to be saved
            return $new_instance;
        }
    function widget($args, $instance) {
            // outputs the content of the widget
        }
    }
    register_widget('My_Widget');
	</pre><p><a href="http://www.darrenhoyt.com/2009/12/22/creating-custom-wordpress-widgets/" class="button-med">Source &amp;rarr;</a></p><h2>Create Custom Shortcodes</h2><p>Shortcodes are a handy way of using code functions within your theme. The advantage of shortcodes is that they can be easily used with the WordPress  post editor.</p><p>Add this code to your <code>functions.php</code>:</p><pre class="brush: php; title: ;" title="">function helloworld() {
return 'Hello World!';
}
add_shortcode('hello', 'helloworld');</pre><p>You can then use [hello] wherever you want to display the content of the shortcode.</p><p><a href="http://wp-snippets.com/add-shortcodes/" class="button-med">Source &amp;rarr;</a></p><h2>Custom Title Length</h2><p>This snippet will allow you to customise the length (by the number of characters) of your post title.</p><p>Paste this code into the <code>functions.php</code>:</p><pre class="brush: php; title: ;" title=""> 
function ODD_title($char)
    {
    $title = get_the_title($post-&amp;gt;ID);
    $title = substr($title,0,$char);
    echo $title;
    }</pre><p>To use this function all you have to do is paste the below code into your theme files, remembering to change the &amp;#8217;20&amp;#8242; to what ever character amount you require:</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php ODD_title(20); ?&amp;gt;
</pre><p><a href="http://www.orangedevdesign.nl/nieuws/wordpress-title-custom-length/" class="button-med">Source &amp;rarr;</a></p><h2>Custom Excerpts</h2><p>Sometimes you may need to limit how many words are in the excerpt, with this snippet you can create your own custom excerpt (my_excerpts) replacing the original.</p><p>Paste this code in <code>functions.php</code>.</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php add_filter('the_excerpt', 'my_excerpts');
function my_excerpts($content = false) {
            global $post;
            $mycontent = $post-&amp;gt;post_excerpt;
 
            $mycontent = $post-&amp;gt;post_content;
            $mycontent = strip_shortcodes($mycontent);
            $mycontent = str_replace(']]&amp;gt;', ']]&amp;amp;gt;', $mycontent);
            $mycontent = strip_tags($mycontent);
            $excerpt_length = 55;
            $words = explode(' ', $mycontent, $excerpt_length + 1);
            if(count($words) &amp;gt; $excerpt_length) :
                array_pop($words);
                array_push($words, '...');
                $mycontent = implode(' ', $words);
            endif;
            $mycontent = '&amp;lt;p&amp;gt;' . $mycontent . '&amp;lt;/p&amp;gt;';
// Make sure to return the content
    return $mycontent;
}
?&amp;gt;</pre><p>Secondly, paste this code within the Loop:</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php echo my_excerpts(); ?&amp;gt;
</pre><p><a href="http://wptricks.net/create-you-own-excerpt-in-wordpress/" class="button-med">Source &amp;rarr;</a></p><h2>Redirect Your Post Titles To External Links</h2><p><img src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2011/03/wp_snippet_01.jpg" alt="Redirect Your Post Titles To External Links"><br /> This snippet could be useful for anyone with a news submission site, by redirecting your post title to an external URL when clicked via a custom field.</p><p>Paste this snippet into your <code>functions.php</code> file:</p><pre class="brush: php; title: ;" title="">//Custom Redirection
function print_post_title() {
global $post;
$thePostID = $post-&amp;gt;ID;
$post_id = get_post($thePostID);
$title = $post_id-&amp;gt;post_title;
$perm  = get_permalink($post_id);
$post_keys = array(); $post_val  = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='url') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '&amp;lt;h2&amp;gt;&amp;lt;a href=&amp;quot;'.$link.'&amp;quot; rel=&amp;quot;bookmark&amp;quot; title=&amp;quot;'.$title.'&amp;quot;&amp;gt;'.$title.'&amp;lt;/a&amp;gt;&amp;lt;/h2&amp;gt;';
}</pre><p>Then you add a custom field named &amp;#8216;url&amp;#8217; and in the value field put the link to which the title is to be redirected to.</p><p><a href="http://www.wprecipes.com/how-to-link-to-some-external-ressource-in-post-title" class="button-med">Source &amp;rarr;</a></p><h2>Redirect to Single Post If There is One Post in Category/Tag</h2><p>If there is only one post within a category or tag, this little snippet will jump the reader directly to the post page.</p><p>Paste this code into your themes <code>functions.php</code> file:</p><pre class="brush: php; title: ;" title=""> 
function stf_redirect_to_post(){
    global $wp_query;
 
    // If there is one post on archive page
    if( is_archive() &amp;amp;&amp;amp; $wp_query-&amp;gt;post_count == 1 ){
        // Setup post data
        the_post();
        // Get permalink
        $post_url = get_permalink();
        // Redirect to post page
        wp_redirect( $post_url );
    }  
 
} add_action('template_redirect', 'stf_redirect_to_post');
</pre><p><a href="http://shailan.com/how-to-redirect-to-single-post-page-if-there-is-one-post-in-categorytag/" class="button-med">Source &amp;rarr;</a></p><h2>List Scheduled/Future Posts</h2><p>Paste the code anywhere on your template where you want your scheduled posts to be listed, changing the max number or displayed posts by changing the value of showposts in the query.</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php
$my_query = new WP_Query('post_status=future&amp;amp;order=DESC&amp;amp;showposts=5');
if ($my_query-&amp;gt;have_posts()) {
    while ($my_query-&amp;gt;have_posts()) : $my_query-&amp;gt;the_post();
        $do_not_duplicate = $post-&amp;gt;ID; ?&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;?php the_title(); ?&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;?php endwhile;
}
?&amp;gt;
</pre><p><a href="http://www.wprecipes.com/how-to-list-scheduled-posts" class="button-med">Source &amp;rarr;</a></p><h2>Screenshots of External Pages Without a Plugin</h2><p>This is a very simple URL script that will generate a screenshot of any website. Here is the URL:</p><pre class="brush: xml; title: ;" title="">http://s.wordpress.com/mshots/v1/http%3A%2F%2Fspeckyboy.com%2F?w=500</pre><p>To see what the link above does, <a href="http://s.wordpress.com/mshots/v1/http%3A%2F%2Fspeckyboy.com%2F?w=500" target="_blank">click here</a>.</p><p>All you have to do is insert your required URL in the place of the &amp;#8216;speckyboy.com&amp;#8217; part of the link and resize (&amp;#8216;w=500&amp;#8242;) as required.</p><h2>Add Content to the End of Each RSS Post</h2><p>Adding some extra content that is only viewable by your RSS subscribers couldn&amp;#8217;t be easier with this snippet.<br /> Paste this code into the functions.php:</p><pre class="brush: php; title: ;" title=""> 
function feedFilter($query) {
    if ($query-&amp;gt;is_feed) {
        add_filter('the_content','feedContentFilter');
    }
    return $query;
}
add_filter('pre_get_posts','feedFilter');
 
function feedContentFilter($content) {
    $content .= '&amp;lt;p&amp;gt;Extra RSS content goes here... &amp;lt;/p&amp;gt;';
 
    return $content;
}
</pre><p><a href="http://wptricks.net/how-to-add-content-to-the-end-of-each-rss-post/" class="button-med">Source &amp;rarr;</a></p><h2>Reset Your WordPress Password</h2><p><img src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2011/03/wp_snippet_02.jpg" alt="Redirect Your Post Titles To External Links"></p><p>What would you do if you forget your WordPress Admin Password and you no longer have access to the admin area? To fix this all you have to do is jump to your PhpMyAdmin Sql-window and run the following command.</p><pre class="brush: sql; title: ;" title="">UPDATE `wp_users` SET `user_pass` = MD5('NEW_PASSWORD') WHERE `wp_users`.`user_login` =`YOUR_USER_NAME` LIMIT 1;</pre><p><a href="http://wp-snippets.com/reset-your-password/" class="button-med">Source &amp;rarr;</a></p><h2>Detect Which Browser Your Visitors are Using</h2><p>If you want to use different stylesheets for different browsers, then this is a snippet you could use. It detects the browser your visitors are using and creates a different class for each browser. You can use that class to create custom stylesheets.</p><pre class="brush: php; title: ;" title="">add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'gecko';
elseif($is_opera) $classes[] = 'opera';
elseif($is_NS4) $classes[] = 'ns4';
elseif($is_safari) $classes[] = 'safari';
elseif($is_chrome) $classes[] = 'chrome';
elseif($is_IE) $classes[] = 'ie';
else $classes[] = 'unknown';
if($is_iphone) $classes[] = 'iphone';
return $classes;
}</pre><p><a href="http://www.nathanrice.net/blog/browser-detection-and-the-body_class-function/" class="button-med">Source &amp;rarr;</a></p><h2>Display Search Terms from Google Users</h2><p>If a visitor reached your site through Google&amp;#8217;s search, this script will display the terms they searched for in order to find your site. Just paste it anywhere outside of the header section.</p><pre class="brush: php; title: ;" title=""> 
&amp;lt;?php
$refer = $_SERVER[&amp;quot;HTTP_REFERER&amp;quot;];
if (strpos($refer, &amp;quot;google&amp;quot;)) {
        $refer_string = parse_url($refer, PHP_URL_QUERY);
        parse_str($refer_string, $vars);
        $search_terms = $vars['q'];
        echo 'Welcome Google visitor! You searched for the following terms to get here: ';
        echo $search_terms;
};
?&amp;gt;
</pre><p><a href="http://wp-snippets.com/display-search-terms-from-google-users/" class="button-med">Source &amp;rarr;</a></p><h2>Show Different Content for Mac &amp;amp; Windows</h2><p>If you ever have the need to display different content to either Mac or Windows users (ie. software download link for different platforms), you can paste the following code into your themes <code>functions.php</code> file. You can easily change the content of the function to your own needs.</p><pre class="brush: php; title: ;" title="">&amp;lt;?php
if (stristr($_SERVER['HTTP_USER_AGENT'],&amp;quot;mac&amp;quot;)) {
echo ‘Hello, I\’m a Mac.’;
} else {
echo ‘And I\’m a PC.’;
}
?&amp;gt;</pre>

Snippets for Wordpress functions

norcross/Custom Post Type ( PHP)

function custom_event_type_css() {
	// This makes sure that the posinioning is also good for right-to-left languages
	$x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#future .form-table td input{margin:0 5px 0 10px;}
	#time .form-table .timestuff {float:left; width:65%;}
	#time .form-table tr span.timefield {float:left;}
	#time .form-table tr span.timeselect {float:right;}
	#date .form-table .timestuff {float:left; width:85%;}
	#date .form-table tr span.timefield {float:left;}
	#date .form-table tr span.timeselect {float:right;}
	#date .form-table tr span.timeselect select {width:130px;} 
	}
	</style>
	";
}

add_action('admin_head', 'custom_event_type_css');



add_action( 'init', 'headline_post_types' );

function headline_post_types() {
	register_post_type( 'headline_list',
		array(
			'labels' => array(
				'name' => __( 'Headlines' ),
				'singular_name' => __( 'Headline' ),
				'add_new' => __( 'Add New' ),
				'add_new_item' => __( 'Add New Headline' ),
				'edit' => __( 'Edit' ),
				'edit_item' => __( 'Edit Headline' ),
				'new_item' => __( 'New Headline' ),
				'view' => __( 'View Headline' ),
				'view_item' => __( 'View Headline' ),
				'search_items' => __( 'Search Headline' ),
				'not_found' => __( 'No headline found' ),
				'not_found_in_trash' => __( 'No headline found in Trash' ),
			),
			'public' => true,
			'show_ui' => true,
			'publicly_queryable' => true,
			'exclude_from_search' => false,
			'menu_position' => 5,
			'capability_type' => 'post',			
			'menu_icon' => get_stylesheet_directory_uri() . '/images/headlines_menu.png',
			'query_var' => true,
			'rewrite' => array( 'slug' => 'headline', 'with_front' => false ),
			'supports' => array('title', 'author', 'revisions', 'custom-fields' ),
		)
	);
}



$meta_boxes = array();

//Headline Info Box


$meta_boxes[] = array(
    'id' => 'summary',
    'title' => 'Headline Summary',
    'pages' => array('headline_list'), // custom post type
	'context' => 'normal',
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Headline Summary',
            'desc' => 'Enter a brief summary of the headline',
            'id' => $prefix . 'headline_summ',
            'type' => 'textarea_sm',
            'std' => ''
        )
    )
);

// Headline Link Box
$meta_boxes[] = array(
    'id' => 'link',
    'title' => 'Headline Link',
    'pages' => array('headline_list'), // custom post type
	'context' => 'normal',
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Headline Link',
            'desc' => 'Enter the link to the headline',
            'id' => $prefix . 'event_link',
            'type' => 'text',
            'std' => ''
        )
    )
);

// Headline Source Box
$meta_boxes[] = array(
    'id' => 'source',
    'title' => 'Headline Source',
    'pages' => array('headline_list'), // custom post type
	'context' => 'normal',
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Headline Source',
            'desc' => 'Enter the source of the headline (i.e. newspaper, magazine, etc)',
            'id' => $prefix . 'event_source',
            'type' => 'text',
            'std' => ''
        )
    )
);

/*********************************

You should not edit the code below

*********************************/

foreach ($meta_boxes as $meta_box) {
	$my_box = new My_meta_box($meta_box);
}

class My_meta_box {

	protected $_meta_box;

	// create meta box based on given data
	function __construct($meta_box) {
		if (!is_admin()) return;
	
		$this->_meta_box = $meta_box;

		// fix upload bug: http://www.hashbangcode.com/blog/add-enctype-wordpress-post-and-page-forms-471.html
		$current_page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1, -4);
		if ($current_page == 'page' || $current_page == 'page-new' || $current_page == 'post' || $current_page == 'post-new') {
			add_action('admin_head', array(&amp;$this, 'add_post_enctype'));
		}
		
		add_action('admin_menu', array(&amp;$this, 'add'));

		add_action('save_post', array(&amp;$this, 'save'));
	}
	
	function add_post_enctype() {
		echo '
		<script type="text/javascript">
		jQuery(document).ready(function(){
			jQuery("#post").attr("enctype", "multipart/form-data");
			jQuery("#post").attr("encoding", "multipart/form-data");
		});
		</script>';
	}

	/// Add meta box for multiple post types
	function add() {
		foreach ($this->_meta_box['pages'] as $page) {
			add_meta_box($this->_meta_box['id'], $this->_meta_box['title'], array(&amp;$this, 'show'), $page, $this->_meta_box['context'], $this->_meta_box['priority']);
		}
	}

	// Callback function to show fields in meta box
	function show() {
		global $post;

		// Use nonce for verification
		echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
	
		echo '<table class="form-table">';

		foreach ($this->_meta_box['fields'] as $field) {
			// get current post meta data
			$meta = get_post_meta($post->ID, $field['id'], true);
		
			echo '<tr>',
					//'<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
					'<td>';
			switch ($field['type']) {
				case 'text':
					echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />',
						'<br />', $field['desc'];
					break;
				case 'textarea':
					echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>',
						'<br />', $field['desc'];
					break;
				case 'textarea_sm':
					echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="2" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>',
						'<br />', $field['desc'];
					break;					
				case 'selecttime':
					echo '<div class="timestuff">','<span class="timefield">',$field['desc'],'</span>', '<span class="timeselect">', '<select name="', $field['id'], '" id="', $field['id'], '">','</span>','</div>';
					foreach ($field['options'] as $option) {
						echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
					}
					echo '</select>';
					break;	
				case 'select':
					echo '<select name="', $field['id'], '" id="', $field['id'], '">';
					foreach ($field['options'] as $option) {
						echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
					}
					echo '</select>';
					break;
				case 'radio':
					foreach ($field['options'] as $option) {
						echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
					}
					break;
				case 'checkbox':
					echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />', $field['desc'];
					break;
				case 'file':
					echo $meta ? "$meta<br />" : '', '<input type="file" name="', $field['id'], '" id="', $field['id'], '" />',
						'<br />', $field['desc'];
					break;
				case 'image':
					echo $meta ? "<img src=\"$meta\" width=\"150\" height=\"150\" /><br />$meta<br />" : '', '<input type="file" name="', $field['id'], '" id="', $field['id'], '" />',
						'<br />', $field['desc'];
					break;
			}
			echo 	'<td>',
				'</tr>';
		}
	
		echo '</table>';
	}

	// Save data from meta box
	function save($post_id) {
		// verify nonce
		if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
			return $post_id;
		}

		// check autosave
		if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) {
			return $post_id;
		}

		// check permissions
		if ('page' == $_POST['post_type']) {
			if (!current_user_can('edit_page', $post_id)) {
				return $post_id;
			}
		} elseif (!current_user_can('edit_post', $post_id)) {
			return $post_id;
		}

		foreach ($this->_meta_box['fields'] as $field) {
			$name = $field['id'];
			
			$old = get_post_meta($post_id, $name, true);
			$new = $_POST[$field['id']];
			
			if ($field['type'] == 'file' || $field['type'] == 'image') {
				$file = wp_handle_upload($_FILES[$name], array('test_form' => false));
				$new = $file['url'];
			}
			
			if ($new &amp;&amp; $new != $old) {
				update_post_meta($post_id, $name, $new);
			} elseif ('' == $new &amp;&amp; $old &amp;&amp; $field['type'] != 'file' &amp;&amp; $field['type'] != 'image') {
				delete_post_meta($post_id, $name, $old);
			}
		}
	}
}

?>

xma/wordpress functions ( PHP)

//when theme fire up...

add_action('after_setup_theme','themeoptions', 16);

function themeoptions(){


//include additional files 
require_once(TEMPLATEPATH . '/theme/themeoptions.php');


load_theme_textdomain( 'mytheme', TEMPLATEPATH.'/languages' );

//sidebar widget

if ( function_exists('register_sidebar') )
    register_sidebar(array(
		'name' => 'Sidebar-sx',
      'before_title' => '<h3>',
      'after_title' => '</h3>',
      'before_widget' => '',
      'after_widget' => '',
    ));

if ( function_exists('register_sidebar') )
    register_sidebar(array(
	'name' => 'Sidebar-dx',
        'before_title' => '<h3>',
        'after_title' => '</h3>',
	'before_widget' => '',
        'after_widget' => '',
    ));

if ( function_exists('register_sidebar') )
    register_sidebar(array(
	'name' => 'advertisement',
        'before_title' => '<h3 class="hide2">',
        'after_title' => '</h3>',
        'before_widget' => '',
        'after_widget' => '',
    ));

//various theme support 

add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats',
		array(
			'aside',             // title less blurb
			'gallery',           // gallery of images
			'link',              // quick link to other site
			'image',             // an image
			'quote',             // a quick quote
			'status',            // a Facebook like status update
			'video',             // video
			'audio',             // audio
			'chat'               // chat transcript
		)
	);
//microformati
add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );

//custom thumbnail size

add_image_size( 'thumb-600', 600, 150, true );
add_image_size( 'thumb-300', 300, 100, true );

//call in theme : <?php the_post_thumbnail( 'thumb-300' ); ?> 
//see more on: http://codex.wordpress.org/Function_Reference/add_image_size
 
//navigation menu
add_theme_support( 'menus' );

if (function_exists('register_nav_menus')) {
	register_nav_menus( array(
	'main-nav' => __( 'Main Navigation'  ),
	'footer-nav' => __( 'Footer Navigation'),
        ) );
}


/* in the theme ...
wp_nav_menu(array(
    	'container' => false,                           // remove nav container
    	'container_class' => 'menu clearfix',           // class of container (should you choose to use it)
    	'menu' => __( 'The Main Menu', 'bonestheme' ),  // nav name
    	'menu_class' => 'nav top-nav clearfix',         // adding custom nav class
    	'theme_location' => 'main-nav',                 // where it's located in the theme
    	'before' => '',                                 // before the menu
        'after' => '',                                  // after the menu
        'link_before' => '',                            // before each link
        'link_after' => '',                             // after each link
        'depth' => 0,                                   // limit the depth of the nav
    	'fallback_cb' => 'bones_main_nav_fallback'      // fallback function
	));
} */


//clean wp-head
remove_action( 'wp_head', 'rsd_link' );
// windows live writer
remove_action( 'wp_head', 'wlwmanifest_link' );
// index link
remove_action( 'wp_head', 'index_rel_link' );
// previous link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
// start link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
// links for adjacent posts
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
// WP version
remove_action( 'wp_head', 'wp_generator' );
// remove WP version from css
// i going to add this 
// remove injected CSS for recent comments widget
// remove injected CSS from recent comments widget
// remove injected CSS from gallery

// replace jquery

if( !is_admin()){
   wp_deregister_script('jquery');
   wp_register_script('jquery', (/*"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js*/ "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false, '1.7.1');
   wp_enqueue_script('jquery');
}
// disable admin bar 

function disable_admin_bar(){
    return false;
}
add_filter( 'show_admin_bar' , 'disable_admin_bar' );


/// related post 
function related_posts() {
	echo '<ul id="related-posts">';
	global $post;
	$tags = wp_get_post_tags($post->ID);
	if($tags) {
		foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
        $args = array(
        	'tag' => $tag_arr,
        	'numberposts' => 5, /* you can change this to show more */
        	'post__not_in' => array($post->ID)
     	);
        $related_posts = get_posts($args);
        if($related_posts) {
        	foreach ($related_posts as $post) : setup_postdata($post); ?>
	           	<li class="related_post"><a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
	        <?php endforeach; }
	    else { ?>
            <?php echo '<li class="no_related_post">' . __( 'No Related Posts Yet!', '' ) . '</li>'; ?>
		<?php }
	}
	wp_reset_query();
	echo '</ul>';
} 


}

function files for worpdress

suibhne/Wordpress Administration Menus ( PHP)

<?php
/*
Plugin Name: Jiltin Plugin Menuadd
Plugin URI: http://www.notesbit.com
Description: Jiltin Plugin Menuadd
Author: Jay
Author URI: http://www.notesbit.com
*/
// Hook for adding admin menus
add_action(‘admin_menu’, ‘mt_add_pages’);

// action function for above hook
function mt_add_pages() {
    // Add a new submenu under Options:
    add_options_page(‘Test Page title Options’, ‘Test menu title Options’, 8, ‘test_file_options’, ‘mt_options_page’);

    // Add a new submenu under Manage:
    add_management_page(‘Test Manage’, ‘Test Manage’, 8, ‘testmanage’, ‘mt_manage_page’);

    // Add a new top-level menu (ill-advised):
    add_menu_page(‘Test Toplevel’, ‘Test Toplevel’, 8, __FILE__, ‘mt_toplevel_page’);

    // Add a new top-level menu (ill-advised):
    // add_menu_page(’Test Toplevel2′, ‘Test Toplevel2′, 8, __FILE__, ‘mt_toplevel_page’);

    // Add a submenu to the custom top-level menu:
    add_submenu_page(__FILE__, ‘Test Sublevel’, ‘Test Sublevel’, 8, ’sub-page’, ‘mt_sublevel_page’);

    // Add a second submenu to the custom top-level menu:
    add_submenu_page(__FILE__, ‘Test Sublevel 2′, ‘Test Sublevel 2′, 8, ’sub-page2′, ‘mt_sublevel_page2′);
}

// mt_options_page() displays the page content for the Test Options submenu
function mt_options_page() {
    echo "<h2>Test Options</h2>";
}

// mt_manage_page() displays the page content for the Test Manage submenu
function mt_manage_page() {
    echo "<h2>Test Manage</h2>";
}

// mt_toplevel_page() displays the page content for the custom Test Toplevel menu
function mt_toplevel_page() {
    echo "<h2>Test Toplevel</h2>";
}

// mt_sublevel_page() displays the page content for the first submenu
// of the custom Test Toplevel menu
function mt_sublevel_page() {
    echo "<h2>Test Sublevel</h2>";
}

// mt_sublevel_page2() displays the page content for the second submenu
// of the custom Test Toplevel menu
function mt_sublevel_page2() {
    echo "<h2>Test Sublevel 2</h2>";
}

?>

Something simple to add all levels of Wordpress menus to a plugin in the admin area.

bigevilbrain/CPT (Custom Post Type) Feed Shortcode ( PHP)

/**
* CPT (Custom Post Type) Feed Shortcode
* http://codex.wordpress.org/Shortcode_API
*/
function fn_cpt( $atts = array(), $content = NULL ) {
	global $post, $wp_query;
	
	$cpt = 'project'; // Custom Post Type slug

	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
	
	// Save and overwrite wp_query so the navigation will work
	$saved_query = $wp_query; $wp_query = null;
	$saved_post = $post; $post = null;
	
	// http://codex.wordpress.org/Function_Reference/WP_Query
	// http://codex.wordpress.org/Template_Tags/get_posts
	$wp_query = new WP_Query();
	$defaults = array(
		'orderby'			=> 'menu_order', // or 'date'
		'order'				=> 'ASC', // or 'DSC'
		'post_type'			=> $cpt,
		// $term->taxonomy	 	=> $term->slug,
		'post_status'		=> 'publish',
		// 'posts_per_page'	=> get_option('posts_per_page', 10),
		// 'paged'			=> $paged,
		'posts_per_page'	=> -1
	);
	$wp_query->query($defaults); // posts_per_page
	
	$output = '';
	
	ob_start();
	if (have_posts()) {
		$count = 0; 
		while (have_posts()) {
			the_post();
			get_template_part('templates/'.$cpt, 'excerpt'); // templates/project-excerpt.php
			if ($count % 4 == 3) {
				echo('<div class="end"></div>');
			}
			$count++;
		}
	}
	
	// Pagination
	get_template_part('templates/nav', 'page'); // templates/nav-page.php
	
	$output = ob_get_clean();
	
	// Restore previous wp_query
	$wp_query = null; $wp_query = $saved_query;
	$post = null; $post = $saved_post;
	
	return $output;
}
add_shortcode('cptfeed', 'fn_cpt');

lawlesscreation/Wordpress Selective page Hierarchy ( PHP)

funtions.php:
/**
 * Create HTML list of pages.
 *
 * @package Razorback
 * @subpackage Walker
 * @author Michael Fields <michael@mfields.org>
 * @copyright Copyright (c) 2010, Michael Fields
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * @uses Walker_Page
 *
 * @since 2010-05-28
 * @alter 2010-10-09
 */
class Razorback_Walker_Page_Selective_Children extends Walker_Page {
    /**
     * Walk the Page Tree.
     *
     * @global stdClass WordPress post object.
     * @uses Walker_Page::$db_fields
     * @uses Walker_Page::display_element()
     *
     * @since 2010-05-28
     * @alter 2010-10-09
     */
    function walk( $elements, $max_depth ) {
        global $post;
        $args = array_slice( func_get_args(), 2 );
        $output = '';

        /* invalid parameter */
        if ( $max_depth < -1 ) {
            return $output;
        }

        /* Nothing to walk */
        if ( empty( $elements ) ) {
            return $output;
        }

        /* Set up variables. */
        $top_level_elements = array();
        $children_elements  = array();
        $parent_field = $this->db_fields['parent'];
        $child_of = ( isset( $args[0]['child_of'] ) ) ? (int) $args[0]['child_of'] : 0;

        /* Loop elements */
        foreach ( (array) $elements as $e ) {
            $parent_id = $e->$parent_field;
            if ( isset( $parent_id ) ) {
                /* Top level pages. */
                if( $child_of === $parent_id ) {
                    $top_level_elements[] = $e;
                }
                /* Only display children of the current hierarchy. */
                else if (
                    ( isset( $post->ID ) &amp;&amp; $parent_id == $post->ID ) ||
                    ( isset( $post->post_parent ) &amp;&amp; $parent_id == $post->post_parent ) ||
                    ( isset( $post->ancestors ) &amp;&amp; in_array( $parent_id, (array) $post->ancestors ) )
                ) {
                    $children_elements[ $e->$parent_field ][] = $e;
                }
            }
        }

        /* Define output. */
        foreach ( $top_level_elements as $e ) {
            $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
        }
        return $output;
    }
}


Insert into template:
/**
 * This will walk the navigation tree but exclude the top level pages.
 * handy for left-hand-nav links
 */
<?php
    $root_page_id = ( empty( $post->ancestors ) ) ? $post->ID : end( $post->ancestors );
    $walker = new Razorback_Walker_Page_Selective_Children();
    wp_list_pages( array(
        'title_li' => '',
        'sort_column' => 'menu_order',
        'child_of' => $root_page_id,
        'walker' => $walker,
    ) );
?>

Originally from: http://wordpress.mfields.org/2010/selective-page-hierarchy-for-wplistpages/

Ijaas/myCategoryOrder Custom Taxonomy mod ( PHP)

<?php
/*
Plugin Name: My Category Order
Plugin URI: http://www.geekyweekly.com/mycategoryorder
Description: My Category Order allows you to set the order in which categories will appear in the sidebar. Uses a drag and drop interface for ordering. Adds a widget with additional options for easy installation on widgetized themes.
Version: 3.0.1
Author: Andrew Charlton &amp; modified by Ijaas (http://www.dex-labs.com)
Author URI: http://www.geekyweekly.com
Author Email: froman118@gmail.com
*/

function mycategoryorder_init() {

function mycategoryorder_menu()
{   
	 add_posts_page(__('My Category Order', 'mycategoryorder'), __('My Category Order', 'mycategoryorder'), 'manage_categories', 'mycategoryorder', 'mycategoryorder');
}

function mycategoryorder_js_libs() {
	if ( isset($_GET['page']) &amp;&amp; $_GET['page'] == "mycategoryorder" )
	{	
		wp_enqueue_script('jquery');
		wp_enqueue_script('jquery-ui-core');
		wp_enqueue_script('jquery-ui-sortable');
	}
}

//Switch page target depending on version
function mycategoryorder_getTarget() {
	return "edit.php";
}

function mycategoryorder_set_plugin_meta($links, $file) {
	$plugin = plugin_basename(__FILE__);
	// create link
	if ($file == $plugin) {
		return array_merge( $links, array( 
			'<a href="' . mycategoryorder_getTarget() . '">' . __('Order Categories', 'mycategoryorder') . '</a>',
			'<a href="http://wordpress.org/tags/my-category-order?forum_id=10#postform">' . __('Support Forum') . '</a>',
			'<a href="http://geekyweekly.com/gifts-and-donations">' . __('Donate') . '</a>' 
		));
	}
	return $links;
}

add_filter('plugin_row_meta', 'mycategoryorder_set_plugin_meta', 10, 2 );
add_action('admin_menu', 'mycategoryorder_menu');
add_action('admin_print_scripts', 'mycategoryorder_js_libs');

//Define selected taxonomy
$tax = ($_GET['mytax'])? $_GET['mytax'] : 'category';
define('myTAXONOMY', $tax, true);

function mycategoryorder()
{
	global $wpdb;
	
	$parentID = 0;
	
	$wpdb->show_errors();

	$query1 = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
	
	if ($query1 == 0) {
		$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'");
	}
	
	if (isset($_POST['btnSubCats'])) { 
		$parentID = $_POST['cats'];
	}
	elseif (isset($_POST['hdnParentID'])) { 
		$parentID = $_POST['hdnParentID'];
	}

	if (isset($_POST['btnReturnParent'])) { 
		$parentsParent = $wpdb->get_row("SELECT parent FROM $wpdb->term_taxonomy WHERE term_id = " . $_POST['hdnParentID'], ARRAY_N);
		$parentID = $parentsParent[0];
	}
		
	if(isset($_GET['hideNote']))
		update_option('mycategoryorder_hideNote', '1');

	$success = "";
	if (isset($_POST['btnOrderCats'])) { 
		$success = mycategoryorder_updateOrder();
	}

	$subCatStr = mycategoryorder_getSubCats($parentID);
	
?>
<div class='wrap'>

<?php //Start of Custom taxonomy ?>
<form name="frmMyCatOrderTax" method="get" action="">
    <input type="hidden" name="page" value="<?php echo $_GET['page']; ?>" />
	<h2><?php _e('My Category Order','mycategoryorder'); ?></h2>
    <?php
		if (get_option("mycategoryorder_hideNote") != "1")
		{ ?>
			<div class="updated">
				<strong><p><?php _e('If you like my plugin please consider donating. Every little bit helps me provide support and continue development.','mycategoryorder'); ?> <a href="http://geekyweekly.com/gifts-and-donations"><?php _e('Donate', 'mycategoryorder'); ?></a>&amp;nbsp;&amp;nbsp;<small><a href="<?php echo mycategoryorder_getTarget(); ?>&amp;hideNote=true"><?php _e('No thanks, hide this', 'mycategoryorder'); ?></a></small></p></strong>
			</div>
	<?php
    	} ?>
        
	<p><?php _e('Choose a taxonomy from the drop down to order its terms','mycategoryorder'); ?></p>
	<?php	
		// Custom Taxonomy dropdown
		$taxes = get_taxonomies(); $taxlist = array();
		echo "<select name='mytax'>";
		foreach($taxes as $tax):
			if(is_taxonomy_hierarchical($tax)):
				$tax = get_taxonomy($tax);
				$s = (myTAXONOMY == $tax->name)? "selected='selected'" : '';
				echo "<option ".$s." value='".$tax->name."'>".$tax->label."</option>";
			endif;
		endforeach;
		echo "</select>";
				
	?>
    <input type="submit" class="button" value="<?php _e('Change Taxonomy', 'mycategoryorder') ?>" />
</form>
<?php //End of Custom taxonomy ?>

<form name="frmMyCatOrder" method="post" action="">
		
	<?php
	echo $success; 
	?>
    
	<p><?php _e('Choose a category from the drop down to order subcategories in that category or order the categories on this level by dragging and dropping them into the desired order.','mycategoryorder'); ?></p>

<?php 
	if($subCatStr != "")
	{ 
	?>
	<h3><?php _e('Order Subcategories','mycategoryorder'); ?></h3>
	<select id="cats" name="cats">
		<?php echo $subCatStr; ?>
	</select>
	&amp;nbsp;<input type="submit" name="btnSubCats" class="button" id="btnSubCats" value="<?php _e('Order Subcategories','mycategoryorder'); ?>" />
	<?php } ?>
	
	<h3><?php _e('Order Categories','mycategoryorder'); ?></h3>
	<ul id="myCategoryOrderList">
	<?php 
	$results= mycategoryorder_catQuery($parentID);
	foreach($results as $row)
		echo "<li id='id_$row->term_id' class='lineitem'>".__($row->name)."</li>";
	?>
	</ul>

	<input type="submit" name="btnOrderCats" id="btnOrderCats" class="button-primary" value="<?php _e('Click to Order Categories', 'mycategoryorder') ?>" onclick="javascript:orderCats(); return true;" />
	<?php echo mycategoryorder_getParentLink($parentID); ?>
	&amp;nbsp;&amp;nbsp;<strong id="updateText"></strong>
	<br /><br />
	<p>
	<a href="http://geekyweekly.com/mycategoryorder"><?php _e('Plugin Homepage', 'mycategoryorder') ?></a>&amp;nbsp;|&amp;nbsp;<a href="http://geekyweekly.com/gifts-and-donations"><?php _e('Donate', 'mycategoryorder') ?></a>&amp;nbsp;|&amp;nbsp;<a href="http://wordpress.org/tags/my-category-order?forum_id=10"><?php _e('Support Forum', 'mycategoryorder') ?></a>
	</p>
	<input type="hidden" id="hdnMyCategoryOrder" name="hdnMyCategoryOrder" />
	<input type="hidden" id="hdnParentID" name="hdnParentID" value="<?php echo $parentID; ?>" />
</form>

</div>

<style type="text/css">
	#myCategoryOrderList {
		width: 90%; 
		border:1px solid #B2B2B2; 
		margin:10px 10px 10px 0px;
		padding:5px 10px 5px 10px;
		list-style:none;
		background-color:#fff;
		-moz-border-radius:3px;
		-webkit-border-radius:3px;
	}

	li.lineitem {
		border:1px solid #B2B2B2;
		-moz-border-radius:3px;
		-webkit-border-radius:3px;
		background-color:#F1F1F1;
		color:#000;
		cursor:move;
		font-size:13px;
		margin-top:5px;
		margin-bottom:5px;
		padding: 2px 5px 2px 5px;
		height:1.5em;
		line-height:1.5em;
	}
	
	.sortable-placeholder{ 
		border:1px dashed #B2B2B2;
		margin-top:5px;
		margin-bottom:5px; 
		padding: 2px 5px 2px 5px;
		height:1.5em;
		line-height:1.5em;	
	}
</style>

<script type="text/javascript">
// <![CDATA[

	function mycategoryrderaddloadevent(){
		jQuery("#myCategoryOrderList").sortable({ 
			placeholder: "sortable-placeholder", 
			revert: false,
			tolerance: "pointer" 
		});
	};

	addLoadEvent(mycategoryrderaddloadevent);
	
	function orderCats() {
		jQuery("#updateText").html("<?php _e('Updating Category Order...', 'mycategoryorder') ?>");
		jQuery("#hdnMyCategoryOrder").val(jQuery("#myCategoryOrderList").sortable("toArray"));
	}

// ]]>
</script>

<?php
}
}

function mycategoryorder_getSubCats($parentID)
{
	global $wpdb;
	
	$subCatStr = "";
	$results=$wpdb->get_results("SELECT t.term_id, t.name FROM $wpdb->term_taxonomy tt, $wpdb->terms t, $wpdb->term_taxonomy tt2 WHERE tt.parent = $parentID AND tt.taxonomy = '".myTAXONOMY."' AND t.term_id = tt.term_id AND tt2.parent = tt.term_id GROUP BY t.term_id, t.name HAVING COUNT(*) > 0 ORDER BY t.term_order ASC");
	foreach($results as $row)
	{
		$subCatStr = $subCatStr."<option value='$row->term_id'>$row->name</option>";
	}

	return $subCatStr;
}

function mycategoryorder_updateOrder()
{
	if (isset($_POST['hdnMyCategoryOrder']) &amp;&amp; $_POST['hdnMyCategoryOrder'] != "") { 
		global $wpdb;
		
		$hdnMyCategoryOrder = $_POST['hdnMyCategoryOrder'];
		$IDs = explode(",", $hdnMyCategoryOrder);
		$result = count($IDs);

		for($i = 0; $i < $result; $i++)
		{
			$str = str_replace("id_", "", $IDs[$i]);
			$wpdb->query("UPDATE $wpdb->terms SET term_order = '$i' WHERE term_id ='$str'");
		}

		return '<div id="message" class="updated fade"><p>'. __('Categories updated successfully.', 'mycategoryorder').'</p></div>';
	}
	else
		return '<div id="message" class="updated fade"><p>'. __('An error occured, order has not been saved.', 'mycategoryorder').'</p></div>';
}

function mycategoryorder_catQuery($parentID)
{
	global $wpdb;
	return $wpdb->get_results("SELECT * FROM $wpdb->terms t inner join $wpdb->term_taxonomy tt on t.term_id = tt.term_id WHERE taxonomy = '".myTAXONOMY."' and parent = $parentID ORDER BY term_order ASC");
}

function  mycategoryorder_getParentLink($parentID)
{
	if($parentID != 0)
		return "&amp;nbsp;&amp;nbsp;<input type='submit' class='button' id='btnReturnParent' name='btnReturnParent' value='" . __('Return to parent category', 'mycategoryorder') ."' />";
	else
		return "";
}

function mycategoryorder_applyorderfilter($orderby, $args)
{
	if($args['orderby'] == 'order')
		return 't.term_order';
	else
		return $orderby;
}

add_filter('get_terms_orderby', 'mycategoryorder_applyorderfilter', 10, 2);

add_action('plugins_loaded', 'mycategoryorder_init');

/* Load Translations */
add_action('init', 'mycategoryorder_loadtranslation');

function mycategoryorder_loadtranslation() {
	load_plugin_textdomain('mycategoryorder', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)), dirname(plugin_basename(__FILE__)));
}


class mycategoryorder_Widget extends WP_Widget {

	function mycategoryorder_Widget() {
		$widget_ops = array('classname' => 'widget_mycategoryorder', 'description' => __( 'Enhanced Category widget provided by My Category Order') );
		$this->WP_Widget('mycategoryorder', __('My Category Order'), $widget_ops);	}

	function widget( $args, $instance ) {
		extract( $args );

		$title_li = apply_filters('widget_title', empty( $instance['title_li'] ) ? __( 'Categories' ) : $instance['title_li']);
		$orderby = empty( $instance['orderby'] ) ? 'order' : $instance['orderby'];
		$order = empty( $instance['order'] ) ? 'asc' : $instance['order'];
		$show_dropdown = (bool) $instance['show_dropdown'];
		$show_last_updated = (bool) $instance['show_last_updated'];
		$show_count = (bool) $instance['show_count'];
		$hide_empty = (bool) $instance['hide_empty'];
		$use_desc_for_title = (bool) $instance['use_desc_for_title'];
		$child_of = empty( $instance['child_of'] ) ? '' : $instance['child_of'];
		$feed = empty( $instance['feed'] ) ? '' : $instance['feed'];
		$feed_image = empty( $instance['feed_image'] ) ? '' : $instance['feed_image'];
		$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
		$exclude_tree = empty( $instance['exclude_tree'] ) ? '' : $instance['exclude_tree'];
		$include = empty( $instance['include'] ) ? '' : $instance['include'];
		$hierarchical = empty( $instance['hierarchical'] ) ? '1' : $instance['hierarchical'];
		$number = empty( $instance['number'] ) ? '' : $instance['number'];
		$depth = empty( $instance['depth'] ) ? '0' : $instance['depth'];

		echo $before_widget;
		if ( $title_li )
			echo $before_title . $title_li . $after_title;

		$cat_args = array('orderby' => $orderby, 'order' => $order, 'show_last_updated' => $show_last_updated, 'show_count' => $show_count, 
			'hide_empty' => $hide_empty, 'use_desc_for_title' => $use_desc_for_title, 'child_of' => $child_of, 'feed' => $feed, 
			'feed_image' => $feed_image, 'exclude' => $exclude, 'exclude_tree' => $exclude_tree, 'include' => $include,
			'hierarchical' => $hierarchical, 'number' => $number, 'depth' => $depth,  );

		if ( $show_dropdown ) {
			static $dropdown_count = 0;

			$cat_id = 'dropdown_'.$args['widget_id'];
			$cat_args['id'] = $cat_args['name'] = $cat_id;
			$cat_args['show_option_none'] = __('Select Category');
			wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
?>

<script type='text/javascript'>
/* <![CDATA[ */
<?php if ( $dropdown_count == 0 ) { ?>
	function onCatChange( dropdownID ) {
		var dropdown = document.getElementById(dropdownID);
		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
			location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
		}
	}
<?php } ?>
	document.getElementById("<?php echo $cat_id; ?>").onchange = function(){onCatChange(this.id)};
/* ]]> */
</script>

<?php
		$dropdown_count++;
		} else {
		?>
		<ul>
		<?php
		$cat_args['title_li'] = '';
		wp_list_categories(apply_filters('widget_categories_args', $cat_args));
		?>
		</ul>
		<?php
		}

		echo $after_widget;
	}

	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;

		if ( in_array( $new_instance['orderby'], array( 'order', 'name', 'count', 'ID', 'slug', 'term_group' ) ) ) {
			$instance['orderby'] = $new_instance['orderby'];
		} else {
			$instance['orderby'] = 'order';
		}
		
		if ( in_array( $new_instance['order'], array( 'asc', 'desc' ) ) ) {
			$instance['order'] = $new_instance['order'];
		} else {
			$instance['order'] = 'asc';
		}
		
		$instance['title_li'] = strip_tags( $new_instance['title_li'] );	
		$instance['show_dropdown'] = strip_tags( $new_instance['show_dropdown'] );
		$instance['show_last_updated'] = strip_tags( $new_instance['show_last_updated'] );
		$instance['show_count'] = strip_tags( $new_instance['show_count'] );
		$instance['hide_empty'] = strip_tags( $new_instance['hide_empty'] );
		$instance['use_desc_for_title'] = strip_tags( $new_instance['use_desc_for_title'] );
		$instance['child_of'] = strip_tags( $new_instance['child_of'] );
		$instance['feed'] = strip_tags( $new_instance['feed'] );
		$instance['feed_image'] = $new_instance['feed_image'];
		$instance['exclude'] = strip_tags( $new_instance['exclude'] );
		$instance['exclude_tree'] = strip_tags( $new_instance['exclude_tree'] );
		$instance['include'] = strip_tags( $new_instance['include'] );
		$instance['hierarchical'] = strip_tags( $new_instance['hierarchical'] );
		$instance['number'] = $new_instance['number'];
		$instance['depth'] = $new_instance['depth'];

		return $instance;
	}
	
	function form( $instance ) {
		//Defaults
		$instance = wp_parse_args( (array) $instance, array( 'orderby' => 'order', 'order' => 'asc', 'title_li' => '', 'show_dropdown' => '', 'show_last_updated' => '', 'show_count' => '', 'hide_empty' => '1', 'use_desc_for_title' => '1', 'child_of' => '', 'feed' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'include' => '', 'hierarchical' => '1', 'number' => '', 'depth' => '' ) );
		
		$orderby = esc_attr( $instance['orderby'] );
		$order = esc_attr( $instance['order'] );
		$title_li = esc_attr( $instance['title_li'] );
		
		$show_dropdown = esc_attr( $instance['show_dropdown'] );
		$show_last_updated = esc_attr( $instance['show_last_updated'] );
		$show_count = esc_attr( $instance['show_count'] );
		$hide_empty = esc_attr( $instance['hide_empty'] );
		$use_desc_for_title = esc_attr( $instance['use_desc_for_title'] );
		$hierarchical = esc_attr( $instance['hierarchical'] );
		
		$child_of = esc_attr( $instance['child_of'] );
		$feed = esc_attr( $instance['feed'] );
		$feed_image = esc_attr( $instance['feed_image'] );
		$exclude = esc_attr( $instance['exclude'] );
		$exclude_tree = esc_attr( $instance['exclude_tree'] );
		$include = esc_attr( $instance['include'] );
		
		$number = esc_attr( $instance['number'] );
		$depth  = esc_attr( $instance['depth'] );

	?>	
		<p>
			<label for="<?php echo $this->get_field_id('orderby'); ?>"><?php _e( 'Order By:', 'mycategoryorder' ); ?></label>
			<select name="<?php echo $this->get_field_name('orderby'); ?>" id="<?php echo $this->get_field_id('orderby'); ?>" class="widefat">
				<option value="order"<?php selected( $instance['orderby'], 'order' ); ?>><?php _e('My Order', 'mycategoryorder'); ?></option>
				<option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e('Name', 'mycategoryorder'); ?></option>
				<option value="count"<?php selected( $instance['orderby'], 'count' ); ?>><?php _e( 'Count', 'mycategoryorder' ); ?></option>
				<option value="ID"<?php selected( $instance['orderby'], 'ID' ); ?>><?php _e( 'ID', 'mycategoryorder' ); ?></option>
				<option value="slug"<?php selected( $instance['orderby'], 'slug' ); ?>><?php _e( 'Slug', 'mycategoryorder' ); ?></option>
				<option value="term_group"<?php selected( $instance['orderby'], 'term_group' ); ?>><?php _e( 'Term Group', 'mycategoryorder' ); ?></option>
			</select>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('order'); ?>"><?php _e( 'Order:', 'mycategoryorder' ); ?></label>
			<select name="<?php echo $this->get_field_name('order'); ?>" id="<?php echo $this->get_field_id('category_order'); ?>" class="widefat">
				<option value="asc"<?php selected( $instance['order'], 'asc' ); ?>><?php _e('Ascending', 'mycategoryorder'); ?></option>
				<option value="desc"<?php selected( $instance['order'], 'desc' ); ?>><?php _e('Descending', 'mycategoryorder'); ?></option>
			</select>
		</p>
				<p>
			<label for="<?php echo $this->get_field_id('title_li'); ?>"><?php _e( 'Title:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $title_li; ?>" name="<?php echo $this->get_field_name('title_li'); ?>" id="<?php echo $this->get_field_id('title_li'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Default to Categories.', 'mycategoryorder' ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('exclude_tree'); ?>"><?php _e( 'Exclude Tree:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $exclude_tree; ?>" name="<?php echo $this->get_field_name('exclude_tree'); ?>" id="<?php echo $this->get_field_id('exclude_tree'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('include'); ?>"><?php _e( 'Include:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $include; ?>" name="<?php echo $this->get_field_name('include'); ?>" id="<?php echo $this->get_field_id('include'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Category IDs, separated by commas.', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('child_of'); ?>"><?php _e( 'Child Of:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $child_of; ?>" name="<?php echo $this->get_field_name('child_of'); ?>" id="<?php echo $this->get_field_id('child_of'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Only display children of this Category ID.', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('feed'); ?>"><?php _e( 'Feed Text:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $feed; ?>" name="<?php echo $this->get_field_name('feed'); ?>" id="<?php echo $this->get_field_id('feed'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Text for RSS Feed', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('feed_image'); ?>"><?php _e( 'Feed Image:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $feed_image; ?>" name="<?php echo $this->get_field_name('feed_image'); ?>" id="<?php echo $this->get_field_id('feed_image'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'URL to RSS Image, copy url of this image', 'mycategoryorder'  ); ?></small><img src="<?php bloginfo('url'); ?>/wp-includes/images/rss.png" alt="RSS" />
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number to Display:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $number; ?>" name="<?php echo $this->get_field_name('number'); ?>" id="<?php echo $this->get_field_id('number'); ?>" class="widefat" />
			<br />
			<small><?php _e( 'Max number of categories to display', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<label for="<?php echo $this->get_field_id('depth'); ?>"><?php _e( 'Depth:', 'mycategoryorder' ); ?></label> <input type="text" value="<?php echo $depth; ?>" name="<?php echo $this->get_field_name('depth'); ?>" id="<?php echo $this->get_field_id('depth'); ?>" class="widefat" />
			<br />
			<small><?php _e( '0 = All, -1 = Flat, 1 = Top Level Only, n = display n levels', 'mycategoryorder'  ); ?></small>
		</p>
		<p>
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_dropdown'], true) ?> id="<?php echo $this->get_field_id('show_dropdown'); ?>" name="<?php echo $this->get_field_name('show_dropdown'); ?>" />
			<label for="<?php echo $this->get_field_id('show_dropdown'); ?>"><?php _e('Show As Dropdown', 'mycategoryorder'); ?></label><br />
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_last_updated'], true) ?> id="<?php echo $this->get_field_id('show_last_updated'); ?>" name="<?php echo $this->get_field_name('show_last_updated'); ?>" />
			<label for="<?php echo $this->get_field_id('show_last_updated'); ?>"><?php _e('Show Last Updated', 'mycategoryorder'); ?></label><br />
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['show_count'], true) ?> id="<?php echo $this->get_field_id('show_count'); ?>" name="<?php echo $this->get_field_name('show_count'); ?>" />
			<label for="<?php echo $this->get_field_id('show_count'); ?>"><?php _e('Show Count', 'mycategoryorder'); ?></label><br />
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hide_empty'], true) ?> id="<?php echo $this->get_field_id('hide_empty'); ?>" name="<?php echo $this->get_field_name('hide_empty'); ?>" />
			<label for="<?php echo $this->get_field_id('hide_empty'); ?>"><?php _e('Hide Empty', 'mycategoryorder'); ?></label><br />
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['use_desc_for_title'], true) ?> id="<?php echo $this->get_field_id('use_desc_for_title'); ?>" name="<?php echo $this->get_field_name('use_desc_for_title'); ?>" />
			<label for="<?php echo $this->get_field_id('use_desc_for_title'); ?>"><?php _e('Use Desc as Title', 'mycategoryorder'); ?></label><br />
			<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hierarchical'], true) ?> id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>" />
			<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e('Show Hierarchical', 'mycategoryorder'); ?></label><br />
		</p>
<?php
	}
}

function mycategoryorder_widgets_init() {
	register_widget('mycategoryorder_Widget');
}

add_action('widgets_init', 'mycategoryorder_widgets_init');

?>

replaced taxonomy = 'category' with taxonomy = '".myTAXONOMY."' add lines 51, 52, 93 - 123