How to Create a Custom Slug for Tags and Categories with a prefix or suffix?

Filter ‘term_link’. Sample code, not tested: add_filter( ‘term_link’, ‘wpse_72848_change_tag_slug’, 10, 3 ); function wpse_72848_change_tag_slug( $termlink, $term, $taxonomy ) { if ( ‘post_tag’ !== $taxonomy ) return $termlink; if ( ‘product’ === $term->slug ) return str_replace( ‘/product/’, ‘/product-powerpoint-ppt/’, $termlink ); return $termlink; }

AJAX search as you type? [duplicate]

I have developed an ajax search plugin a few weeks ago. There is a free version available at the wordpress plugin repository. Feel free to explore the source code 🙂 You can find it here: Ajax Search Lite There is also a commercial version, maybe you are interested: Ajax Search Pro You can check out … Read more

options creation for plugins

There are some functions associated with manipulating the variables found in the wp_options table. add_option(): Create a new value in the table. Example add_option(‘var_name’, ‘value’) will store option_name=”var_name” and option_value=”value”. add_option() is used only when saving a value for the first time. Has an autoload parameter. get_option(): Retrieve that value. Example: get_option(‘var_name’) will return the … Read more

Count posts by type including drafts and pending posts

It’s not necessary to use $wpdb, a simple get_posts can handle it. Check WP_Query for the full list of parameters. function count_user_posts_by_type( $userid, $post_type ) { $args = array( ‘numberposts’ => -1, ‘post_type’ => $post_type, ‘post_status’ => array( ‘publish’, ‘private’, ‘draft’, ‘pending’ ), ‘author’ => $userid ); $count_posts = count( get_posts( $args ) ); return … Read more