• Resolved notkristina

    (@notkristina)


    My site includes some guest authors that don’t yet have posts, but I would like them still to have profile pages.

    1. I’ve already successfully redirected the 404 page to use the author page template in the event that the query was for an author.
    2. I’ve extracted (from the query) the taxonomy term ID and slug of the co-author sought. This may not have been the most direct way to go about getting that information, but I have it.

    What I can’t figure out is how to use the term ID or slug to pull a guest author’s Co-Authors info, at the very least their display name and email. Do you have any advice?

    http://wordpress.org/extend/plugins/co-authors-plus/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    I think you can actually just hack it with something like this:

    add_action( 'template_redirect', 'capx_template_redirect' );
    function capx_template_redirect() {
    	global $wp_query;
    
    	if ( false !== stripos( $_SERVER['REQUEST_URI'], '/author' ) && empty( $wp_query->posts ) ) {
    		$wp_query->is_404 = false;
    		get_template_part( 'author' );
    		exit;
    	}
    
    }

    Basically, it forces author.php to load if it would otherwise 404. Can you try that on for size?

    Thread Starter notkristina

    (@notkristina)

    Thank you—this is a far better and tidier way of doing what I had done so far to force the 404 to load the author template, but even still the author info doesn’t load on the page.

    In the widget that should show the author profile, it loads nothing. How can I tell it who the author is?

    Thread Starter notkristina

    (@notkristina)

    For clarity’s sake, here’s a snippet of the author profile code from the author template, to show precisely how I’m calling the data. This retrieves the author info successfully on the pages of guest authors that have posts, but not on the author template when replacing a 404—possibly because instead of the author ID, the query is looking for the taxonomy term ID, which is a different number? But since it works on authors with posts, I’m not sure that makes any difference.

    echo get_the_author_meta('first_name').' '.get_the_author_meta('last_name');
    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    If you use get_queried_object() on an author.php template, it should give you an $author object (which is just a user object). You could do something like:

    $author = get_queried_object();
    echo $author->first_name . ' ' . $author->last_name;
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Advice for showing author profile page for authors without posts?’ is closed to new replies.