3424 readersWordPress have lots of useful built-in function, unfortunely there's no function to allow the quick edition of a term (category, tag, or custom term). Nevermind, we can still built our own.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip: How to make term edition
4737 readers
PHP
function __search_by_title_only( $search, &$wp_query )
{
if ( empty($search) )
return $search; // skip processing - no search term in query
$q =& $wp_query->query_vars;
// wp-includes/query.php line 2128 (version 3.1)
$n = !empty($q['exact']) ? '' : '%';
7194 readers
PHP
function get_related_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
$output = '';
foreach ( $authors_posts as $authors_post ) {
$output .= ''
4235 readersI recently shown you jow you can create a post or a comment programatically, which is very usefull when creating advanced WOrdPress themes or plugins. Today, let's have a look at another killer snippet: Add categories or tags to a posts, programatically.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you
3419 readersThe default output for WordPress’ post_class template tag includes class names for just about every type of page view imaginable:
page-parent
search-results
logged-in
author
paged
Plus just about everything else except for category ID information. It gives some good category-specific class names, but nothing to represent the category ID. For example, including the post_class function like this in your markup:
<div <?php
3809 readersThe post_class() function in WordPress is pretty darn useful. It is used like this, in most templates, in a wrapping div of all the content you are outputting:
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<!-- Post stuff -->
</div>
I was in a circumstance where I wanted to add an additional class to what that
4402 readersIn blogging, it is useful to be able to display your most popular posts. There's WordPress plugins to do that, but you don't need it: This code will display your most popular posts, accordoing to the comments count, without requiring you to use a plugin.Looking for WordPress hosting? Try WP Web Host. Prices starts at
6188 readers
PHP
add_filter('the_terms', 'the_terms_function_filter',10,5);
function the_terms_function_filter($term_list, $taxonomy, $before, $sep, $after){
return strip_tags($them_list);
}
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It | DesignPoke-it
1104 readers
( example screenshot )PHP
add_action( 'admin_head-edit-tags.php', 'admin_edit_tags' );
function admin_edit_tags() {
add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );
}
function admin_trim_category_description( $terms, $taxonomies ) {
if( 'category' != $taxonomies[0] )
return $terms;
foreach( $terms as $key=>$term )
2695 readersWe covered how to run a shortcode in a widget. But what about inserting a widget with a shortcode? I recently had this situation come up. I had a single page where I just wanted to be able to chuck in a widget without the whole rigmarole of creating a special widgetized area and probably