• Hello!

    First of all, congratulations for your excellent software.

    I would like to display the author’s bio on the Author page (except for the Post page, of course).

    For example https://www.pontikis.net/author/pontikis

    I use the Oceanwp Child theme. I suppose I have to copy and modify some template file to the child theme folder.

    Could you please help me with this? Which file do I have to copy? What kind of modifications I have to make? Is there another way to do it?

    Best Regards

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    Thank you so much. Your feedback is highly appreciated.

    Try to add the following code in functions.php file of your child theme.

    function owp_add_author_bio() {
    
        $description = get_the_author_meta( 'description' );
    
        if ( $description && is_author() ) {
    
            echo '<div class="author-bio-description clr">';
                echo wp_kses_post( $description );
            echo '</div><!-- author-bio-description -->';
        }
    }
    add_action( 'ocean_before_blog_entry_title', 'owp_add_author_bio' );

    To change the location, hook it using ocean hooks plugin.

    # You can edit the code as per your need to style, and hook it on a different location where you want.

    Thread Starter Christos Pontikis

    (@pontikis)

    Thank you very much for your swift reply!

    Not only an amazing theme but with amazing support too!

    Well, as I want to display the bio once on the page I used “ocean_before_content” hook https://docs.oceanwp.org/article/404-before-content

    Additionally, I display the user image and URL.

    The result looks amazing to me.

    Here is the code, hoping to be useful to other OceanWP users.

    
    function owp_add_author_bio() {
    
        if ( is_author() ) {
    
        	$description = get_the_author_meta( 'description' );
    
        	if ($description) {
    
    			$author_id = get_the_author_meta('ID');
    			$author_gravatar = get_avatar_url($author_id, array('size' => 200));
    
    			if ($author_gravatar) {
    				$author_nickname = get_the_author_meta('nickname');
    		        echo '<div class="author-image clr" style="margin-bottom: 10px;">';
    	    		echo '<img src="'.$author_gravatar.'" alt="'. $author_nickname . '" style="width: 200px; border-radius: 50%; display:block; margin:auto;" />';
    		        echo '</div><!-- author-image -->';
    			}
    
    	        echo '<div class="author-bio-description clr" style="margin-bottom: 20px;">';
    	            echo wp_kses_post( $description );
    	        echo '</div><!-- author-bio-description -->';
    
    	        $user_url = get_the_author_meta( 'user_url' );
    	        if ($user_url) {
    		        echo '<div class="author-url clr" style="margin-bottom: 50px;">';
    		            echo '<a href="' . $user_url . '" target="_blank" rel="nofollow">' . $user_url . '</a>';
    		        echo '</div><!-- author-url -->';
    	        }
    
    		    echo '<hr>';
        	}
    
        }
    }
    add_action( 'ocean_before_content', 'owp_add_author_bio' );
    

    Once again, thank you very much!

    You are the most welcome! and Thank you so much for sharing the solution with us.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Author bio in Author page’ is closed to new replies.