resolve /author/ to a page or archive (of all authors) template

If you use code similar to setup the rewrite rules: function ex_rewrite( $wp_rewrite ) { $feed_rules = array( ‘author/?$’ => ‘index.php?author_page=author_page’ ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; return $wp_rewrite; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( ‘generate_rewrite_rules’, ‘ex_rewrite’ ); followed by code to add the author_page as … Read more

wp_list_authors including custom post types

Add the following function in functions.php and use custom_wp_list_authors function in place of wp_list_authors in your theme where you want to display authors who wrote custom post types post. function custom_wp_list_authors($args=””) { global $wpdb; $defaults = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘number’ => ”, ‘optioncount’ => false, ‘exclude_admin’ => true, ‘show_fullname’ => false, … Read more

How to make an author archive only for certain user role and show related CPT

You can display user posts using user’s ID. This code might provide a quick sample on how to do it (I have not tested the code). $user_id = $_GET[‘author_id’]; //The Query query_posts(“author={$user_id}”); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); echo “<br>”; endwhile; else: echo “No Posts!”; endif; //Reset … Read more

Refine custom posts by author

Three steps need to be followed to accomplish it. 1. Add rewrite rules add_action(‘generate_rewrite_rules’, ‘author_cpt_add_rewrite_rules’); function author_cpt_add_rewrite_rules( $wp_rewrite ) { $new_rules = array( ‘author/(.+)/(.+)’ => ‘index.php?author=”.$wp_rewrite->preg_index(1) . “&post_type=” .$wp_rewrite->preg_index(2) ); //​ Add the new rewrite rule into the top of the global rules array $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } 2. Redirect to specific templates … Read more

Get $curauth level

toscho is correct. User levels have been deprecated for a long time now. However, the following will get you the available information about the author of the posts on an author archive page. $author = get_queried_object(); var_dump($author); In that dump you should see everything you need, but use the role not the user level– look … Read more

Author archive only for custom post type

According to this blogpost you just need to add the following code to your themes functions.php or in a plugin: /* Add CPTs to author archives */ function custom_post_author_archive($query) { if ($query->is_author) $query->set( ‘post_type’, array(‘custom_type’, ‘post’) ); remove_action( ‘pre_get_posts’, ‘custom_post_author_archive’ ); } add_action(‘pre_get_posts’, ‘custom_post_author_archive’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)