Author.php not displaying post type posts
Ok, I got it… by query all the post types $arg = array(‘post_type’=> array (‘cpt’,’post’),); query_posts( $arg);
Ok, I got it… by query all the post types $arg = array(‘post_type’=> array (‘cpt’,’post’),); query_posts( $arg);
Try reviewing this page on the codex. Using your above template, I would suggest the following: <?php if ( is_user_logged_in() ) : $args = array( ‘posts_per_page’ => ‘5’, ‘author’ => get_current_user_id(), // Removes a few lines of code 😉 ); $author_posts = new WP_Query( $args ); ?> <?php /* Author has posts? */ ?> <?php … Read more
The WP_Query class will automatically AND any filters that are set. In your case, using $query->set( ‘meta_query’, … ) means that WordPress will be looking for posts from the current author (because this is the author template) AND that have your custom meta key. From my understanding of your problem, this intentionally will never happen, … Read more
You may be able to abuse add_rewrite_endpoint for this purpose, depending on exactly what you want to do. Some examples: // add an endpoint // http:domain.com/role/ // http:domain.com/role/foo/ function wpa_add_role_endpoint(){ add_rewrite_endpoint( ‘role’, EP_ALL ); } add_action( ‘init’, ‘wpa_add_role_endpoint’ ); // check if a role parameter exists, like: // http:domain.com/role/foo/ function wpa_role_query( $query ){ if( $query->get(‘role’) … Read more
A combination of get_queried_object_id to fetch the current user ID and get_user_meta to retrieve the banner should do the trick. <?php // somewhere in your theme’s author.php if ($img = get_user_meta(get_queried_object_id(), ‘user_banner’, true)) { // they uploaded an image, use it } else { // they did not upload the image, show the default }
On an “author” page you can get a lot of the information you need with get_queried_object and additional information with get_user_meta. What you want (sounds like) should be in that second chunk of information.That is… $author = $wp_query->get_queried_object(); $ameta = get_user_meta($author->ID); var_dump($author,$ameta); // debugging if(!empty($ameta[‘facebook’])) { var_dump($ameta[‘yim’]); // debugging } // and so one for … Read more
Got the answer, encase anyone else needs it, here it is. <?php $currauthor_id = get_the_author_meta(‘ID’); $terms = get_terms(‘your_taxonomy’, array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 1, ) ); foreach ( $terms as $term ) { $myquery = new WP_Query( array( ‘author’ => $currauthor_id, ‘post_type’ => ‘post_type_name’, ‘your_taxonomy’ => $term->slug, ‘posts_per_page’ = > -1, … Read more
Use get_comment_author_link() instead of <a href … </a>: echo get_comment_author_link();
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
Just a simple logic error. You want to display the header if you’re not on the front page AND if you’re not on an author page. if(!is_front_page() && !is_author() ) {