Adding meta values to permalink

Was able to get this working. Thought I would write down what we did in the hopes that it will help someone in the future (or someone can give me feedback on how to better improve it!) Registered Custom Rewrite Rules add_action(‘init’, ‘pub_rewrite_rules’); function pub_rewrite_rules() { global $wp_rewrite; $wp_rewrite->add_rewrite_tag( ‘%pubyear%’, ‘([0-9]{4})’, ‘pubyear=”); $wp_rewrite->add_rewrite_tag( “%pubmonth%’, ‘([0-9]{2})’, … Read more

Set custom upload path for custom post type only?

You can add a filter to upload_dir. Here is a simple class I wrote to do this for a project. Use the protected $filter_path variable to define the alternate uploads directory (*will be relative to wp-content/uploads) class UGC_Attachment { protected $upload_dir; protected $upload_url; protected $filter_path=”/relative_path_from_wp-content/uploads”; function __construct() { $dir = wp_upload_dir(); $this->upload_dir = $dir[‘basedir’] . … Read more

Get all authors with at least one post of ‘custom post type’

For now post_type support is not currently available for count_user_posts(), so put the below code in theme’s functions.php file. function count_user_posts_by_type( $userid, $post_type=”post” ) { global $wpdb; $where = get_posts_by_author_sql( $post_type, true, $userid ); $count = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->posts $where” ); return apply_filters( ‘get_usernumposts’, $count, $userid ); } Now this function would take … Read more