Jump to content

Wordpress Mod: Display Meta and Logged In User Icon


WebKeyDesign

Recommended Posts

For this mod, the easiest way to display the Meta data on the sidebar of your theme is to use the built-in Meta widget. Once you add the Meta widget to your theme, you can edit it to make the user icon appear.

In the current version of Wordpress 6.2, you can edit the following file:

\wp-includes\widgets\class-wp-widget-meta.php

 

Search for the following code:

<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>

This is the beginning of the displayed meta. This code is inside a ul tag. You will want to add the code below after the closing ul tag.

Add code:

<ul>
	<li>
		<?php
    		global $current_user;
    		if ( is_user_logged_in() ):
        	get_currentuserinfo();     
        	echo get_avatar( $current_user->ID, 128 );
    		endif;  
		?>
	</li>
</ul>

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...