Common Data and Retrieval Methods Used in a WordPress Front-End User Center

When developing a regular WordPress theme, we usually have plenty of existing themes to learn from. But when building a WordPress front-end user center, examples are much harder to find, probably because the demand is smaller than it is for ordinary themes. This article introduces some of the data retrieval methods that are often used when developing a WordPress front-end user center.

Global variables

$authordata
$post
$wp_query
echo get_author_posts_url( $authordata->ID );

Get the author display name

echo esc_attr( $authordata ->display_name )

Get the comment count inside the loop

echo $post->comment_count
comments_link()

Get the current logged-in user

$current_user = wp_get_current_user();

Get the user object you want to work with

global $wp_query;
$author = $wp_query->get_queried_object();

The examples above cover some of the data access patterns that are commonly used when developing a front-end user center. They are only part of the picture, and I will keep adding to the list as I continue building front-end user center features.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *