本文整理汇总了PHP中get_the_author函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_author函数的具体用法?PHP get_the_author怎么用?PHP get_the_author使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_author函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: presscore_search_title_shortcode
function presscore_search_title_shortcode()
{
$title = '';
$wrap_class = '';
if (is_search()) {
$title = get_search_query();
} else {
if (is_archive()) {
if (is_category()) {
$title = single_cat_title('', false);
} elseif (is_tag()) {
$title = single_tag_title('', false);
} elseif (is_author()) {
the_post();
$title = '<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta("ID"))) . '" title="' . esc_attr(get_the_author()) . '" rel="me">' . get_the_author() . '</a>';
$wrap_class .= ' vcard';
rewind_posts();
} elseif (is_day()) {
$title = '<span>' . get_the_date() . '</span>';
} elseif (is_month()) {
$title = '<span>' . get_the_date('F Y');
} elseif (is_year()) {
$title = '<span>' . get_the_date('Y');
} elseif (is_tax('dt_portfolio_category')) {
$title = single_term_title('', false);
} elseif (is_tax('dt_gallery_category')) {
$title = single_term_title('', false);
}
}
}
if ($title) {
$title = '<span' . ($wrap_class ? ' class="' . esc_attr($wrap_class) . '"' : '') . '>' . $title . '</span>';
}
return $title;
}
示例2: twentysixteen_entry_meta
function twentysixteen_entry_meta()
{
ob_start();
if ('post' === get_post_type()) {
ob_start();
twentysixteen_entry_date();
$postedOn = ob_get_clean();
$author_avatar_size = apply_filters('twentysixteen_author_avatar_size', 49);
printf('<div class="name-date"><div class="name"><span class="screen-reader-text">%2$s </span> <a class="url fn n" href="%3$s">%4$s</a></div><div class="date">%5$s</div></div><div class="avatar">%1$s</div>', get_avatar(get_the_author_meta('user_email'), $author_avatar_size), _x('Author', 'Used before post author name.', 'twentysixteen'), esc_url(get_author_posts_url(get_the_author_meta('ID'))), get_the_author(), $postedOn);
}
if (in_array(get_post_type(), array('attachment'))) {
twentysixteen_entry_date();
}
$authordate = ob_get_clean();
printf('<div class="author-date">%s</div>', $authordate);
$format = get_post_format();
if (current_theme_supports('post-formats', $format)) {
printf('<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>', sprintf('<span class="screen-reader-text">%s </span>', _x('Format', 'Used before post format.', 'twentysixteen')), esc_url(get_post_format_link($format)), get_post_format_string($format));
}
echo '<div class="taxonomies">';
if ('post' === get_post_type()) {
twentysixteen_entry_taxonomies();
}
echo '</div>';
if (!is_singular() && !post_password_required() && (comments_open() || get_comments_number())) {
echo '<span class="comments-link">';
comments_popup_link(sprintf(__('Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentysixteen'), get_the_title()));
echo '</span>';
}
}
示例3: square_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function square_posted_on()
{
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$posted_on = sprintf(esc_html_x('%s', 'post date', 'square'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
$byline = sprintf(esc_html_x('by %s', 'post author', 'square'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
$comment_count = get_comments_number();
// get_comments_number returns only a numeric value
if (comments_open()) {
if ($comment_count == 0) {
$comments = __('No Comments', 'square');
} elseif ($comment_count > 1) {
$comments = $comment_count . __(' Comments', 'square');
} else {
$comments = __('1 Comment', 'square');
}
$comment_link = '<a href="' . get_comments_link() . '">' . $comments . '</a>';
} else {
$comment_link = __(' Comment Closed', 'square');
}
echo '<span class="posted-on"><i class="fa fa-clock-o"></i>' . $posted_on . '</span><span class="byline"> ' . $byline . '</span><span class="comment-count"><i class="fa fa-comments-o"></i>' . $comment_link . "</span>";
// WPCS: XSS OK.
}
示例4: test_get_the_author
function test_get_the_author()
{
$author_name = get_the_author();
$user = new WP_User($this->author_id);
$this->assertEquals($user->display_name, $author_name);
$this->assertEquals('test_author', $author_name);
}
示例5: getRecent
/**
* Latest blog posts
*
* @param int $limit post display limit
*
* @param string $thumbnail_size
*
* @return array
*/
public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
{
$args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
$array_out = array();
$recent_posts = \get_posts(\wp_parse_args($args));
/*$like_bool = Option::get_theme_option( 'blog_list_like' );
if ( $like_bool === '1' ) {
$PostLike = \SilverWp\Ajax\PostLike::getInstance();
}*/
foreach ($recent_posts as $key => $recent) {
\setup_postdata($recent);
$post_id = $recent->ID;
//$array_out[ $key ] = $recent;
$array_out[$key]['ID'] = $post_id;
$array_out[$key]['post_title'] = \get_the_title($post_id);
$array_out[$key]['url'] = \get_the_permalink($post_id);
$array_out[$key]['post_author'] = \get_the_author();
$array_out[$key]['post_date'] = \get_the_date('', $post_id);
$array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
//$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
$array_out[$key]['post_comment_count'] = $recent->comment_count;
if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
$array_out[$key]['post_excerpt'] = \get_the_excerpt();
} else {
$array_out[$key]['post_excerpt'] = $recent->post_excerpt;
}
$array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
// Thumbnail
$array_out[$key]['categories'] = self::getTaxonomy($post_id);
}
\wp_reset_postdata();
return $array_out;
}
示例6: ushipnetwork_entry_footer
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function ushipnetwork_entry_footer()
{
// Hide category and tag text for pages.
if ('post' === get_post_type()) {
$byline = sprintf(esc_html_x('by %s', 'post author', 'ushipnetwork'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
echo '<div class="byline">' . '<div class="authorship">' . $byline . '</div>' . '<div class="share">';
include "share.php";
echo '</div>' . '</div>';
$posttags = get_the_tags();
$count = 0;
$separator = ', ';
$output = '';
if (!empty($posttags)) {
echo '<span class="tag-list">tags: ';
foreach ($posttags as $posttag) {
$count++;
if ($count <= 2) {
$output .= '<a href="' . esc_url(get_tag_link($posttag->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', 'textdomain'), $posttag->name)) . '">' . esc_html($posttag->name) . '</a>' . $separator;
}
}
echo trim($output, $separator);
}
echo '</span>';
}
edit_post_link(sprintf(esc_html__('Edit %s', 'ushipnetwork'), the_title('<span class="screen-reader-text">"', '"</span>', false)), '<span class="edit-link">', '</span>');
}
示例7: bl_posttype_shortcodes_showposts
function bl_posttype_shortcodes_showposts($params = array())
{
// Pulls the paramater values passed from the shortcode options
extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
// Builds the query based on the available params
$query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
// Looks for the presence of any qualifying posts inside the defined loop
if ($query->have_posts()) {
// We open the post container only where specified posts are available
$shortcodeOutput = '<div>';
while ($query->have_posts()) {
$query->the_post();
// Wraps each qualifying post for output in an <article> tag with Schema data.
$shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
$shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
$shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
$shortcodeOutput .= '</a>';
$shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
$shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
$shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
$shortcodeOutput .= '<article>';
}
// Closes off the parent container
$shortcodeOutput .= '</div>';
}
// Resets the wordpress loop
wp_reset_postdata();
// Returns the concatenated shortcodeOutput to the page
return $shortcodeOutput;
}
示例8: sociallyviral_archive_title
/**
* Shim for `sociallyviral_archive_title()`.
*
* Display the archive title based on the queried object.
*
* @todo Remove this function when WordPress 4.3 is released.
*
* @param string $before Optional. Content to prepend to the title. Default empty.
* @param string $after Optional. Content to append to the title. Default empty.
*/
function sociallyviral_archive_title($before = '', $after = '')
{
if (is_category()) {
$title = sprintf(__('Category: %s', 'sociallyviral'), single_cat_title('', false));
} elseif (is_tag()) {
$title = sprintf(__('Tag: %s', 'sociallyviral'), single_tag_title('', false));
} elseif (is_author()) {
$title = sprintf(__('Author: %s', 'sociallyviral'), '<span class="vcard">' . get_the_author() . '</span>');
} elseif (is_year()) {
$title = sprintf(__('Year: %s', 'sociallyviral'), get_the_date(_x('Y', 'yearly archives date format', 'sociallyviral')));
} elseif (is_month()) {
$title = sprintf(__('Month: %s', 'sociallyviral'), get_the_date(_x('F Y', 'monthly archives date format', 'sociallyviral')));
} elseif (is_day()) {
$title = sprintf(__('Day: %s', 'sociallyviral'), get_the_date(_x('F j, Y', 'daily archives date format', 'sociallyviral')));
} elseif (is_post_type_archive()) {
$title = sprintf(__('Archives: %s', 'sociallyviral'), post_type_archive_title('', false));
} elseif (is_tax()) {
$tax = get_taxonomy(get_queried_object()->taxonomy);
/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
$title = sprintf(__('%1$s: %2$s', 'sociallyviral'), $tax->labels->singular_name, single_term_title('', false));
} else {
$title = __('Archives', 'sociallyviral');
}
/**
* Filter the archive title.
*
* @param string $title Archive title to be displayed.
*/
$title = apply_filters('get_the_archive_title', $title);
if (!empty($title)) {
echo $before . $title . $after;
}
}
示例9: kanec_entry_meta
/**
* This is a duplicate of the above. Probably delete others
*/
function kanec_entry_meta()
{
// Time
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
echo '<div class="posted-on"><i class="icon icon-calendar-o"></i><a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a></div>';
// Author
echo '<div class="byline"><i class="icon icon-user"></i><span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span></div>';
// Categories & Tags
// Hide category and tag text for pages.
if ('post' === get_post_type()) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list(esc_html__(', ', 'kanec'));
if ($categories_list && kanec_categorized_blog()) {
echo '<div class="cat-links"><i class="icon icon-folder-open"></i>' . $categories_list . '</div>';
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list('', esc_html__(', ', 'kanec'));
if ($tags_list) {
echo '<div class="tags-links"><i class="icon icon-tags"></i>' . $tags_list . '</div>';
}
}
if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
echo '<div class="comments-link"><i class="icon icon-comments"></i>';
comments_popup_link(esc_html__('Leave a comment', 'kanec'), esc_html__('1 Comment', 'kanec'), esc_html__('% Comments', 'kanec'));
echo '</div>';
}
}
示例10: river_radio_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function river_radio_posted_on()
{
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if (get_the_time('U') !== get_the_modified_time('U')) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$posted_on = sprintf(esc_html_x('%s', 'post date', 'river-radio'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
$byline = sprintf(esc_html_x('%s', 'post author', 'river-radio'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
echo '<span class="byline icons"><i class="fa fa-headphones"></i>
' . $byline . '</span><span class="posted-on icons"><i class="fa fa-calendar"></i>
' . $posted_on . '</span>';
// WPCS: XSS OK.
if ('post' === get_post_type()) {
$tags_list = get_the_tag_list('', esc_html__(', ', 'river-radio'));
if ($tags_list) {
printf('<span class="tags-links icons"><i class="fa fa-music"></i>
' . esc_html__('%1$s', 'river-radio') . '</span> ', $tags_list);
// WPCS: XSS OK.
}
$categories_list = get_the_category_list(esc_html__(', ', 'river-radio'));
if ($categories_list && river_radio_categorized_blog()) {
printf('<span class="cat-links icons"><i class="fa fa-map-marker"></i>
' . esc_html__('%1$s', 'river-radio') . '</span>', $categories_list);
// WPCS: XSS OK.
}
}
}
示例11: impronta_metadata
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function impronta_metadata()
{
// Hide category and tag text for pages.
if ('post' === get_post_type()) {
echo '<p class="metadata">';
$byline = sprintf(esc_html_x('By %s', 'post author', 'impronta'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span> ');
echo $byline;
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list(esc_html__(', ', 'impronta'));
if ($categories_list && impronta_categorized_blog()) {
printf('<span class="cat-links">' . esc_html_x('on %1$s ', 'on categories', 'impronta') . '</span>', $categories_list);
// WPCS: XSS OK.
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list('', esc_html__(', ', 'impronta'));
if ($tags_list) {
printf(esc_html__('tagged %1$s', 'impronta'), $tags_list);
// WPCS: XSS OK.
}
if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
if (get_comments_number(get_the_id()) == 0) {
echo esc_html__('- ', 'impronta');
} else {
echo esc_html__('with ', 'impronta');
}
comments_popup_link(esc_html__('Leave a comment', 'impronta'), esc_html__('1 Comment', 'impronta'), esc_html__('% Comments', 'impronta'));
}
if (is_sticky()) {
echo ' - ' . '<i class="feature-star fa fa-star" data-toggle="tooltip" data-placement="right" title="' . esc_attr__('Featured Post', 'impronta') . '"></i>';
}
echo '</p>';
}
}
示例12: df_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function df_posted_on()
{
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$author = __('by', 'dahztheme') . ' ' . sprintf('<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_html(get_the_author()));
printf('<span class="posted-on">%1$s</span><span class="byline">%2$s</span>', sprintf('<a href="%1$s" rel="bookmark">%2$s</a>', esc_url(get_permalink()), $time_string), $author);
}
示例13: wheels_entry_meta
/**
* Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
*
* @return void
*/
function wheels_entry_meta()
{
if (is_sticky() && is_home() && !is_paged()) {
echo '<span class="featured-post">' . __('Sticky', 'wheels') . '</span>';
}
if (!has_post_format('link') && 'post' == get_post_type()) {
wheels_entry_date();
}
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list(__(', ', 'wheels'));
if ($categories_list) {
echo '/<span class="categories-links">' . $categories_list . '</span>';
}
// Translators: used between list items, there is a space after the comma.
$tag_list = get_the_tag_list('', __(', ', 'wheels'));
if ($tag_list) {
echo '/<span class="tags-links">' . $tag_list . '</span>';
}
// Post author
if ('post' == get_post_type()) {
printf('/<span class="author vcard">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author">%4$s</a></span>', __('by', 'wheels'), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'wheels'), get_the_author())), get_the_author());
$num_comments = get_comments_number();
// get_comments_number returns only a numeric value
if ($num_comments == 0) {
} else {
if ($num_comments > 1) {
$comments = $num_comments . __(' Comments', 'wheels');
} else {
$comments = __('1 Comment', 'wheels');
}
echo $write_comments = '/<span class="comments-count"><a href="' . get_comments_link() . '">' . $comments . '</a></span>';
}
}
}
示例14: tokopress_entry_meta
function tokopress_entry_meta()
{
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list(__(', ', 'tokopress'));
// Translators: used between list items, there is a space after the comma.
$tag_list = get_the_tag_list('', __(', ', 'tokopress'));
$date = sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()));
$author = sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'tokopress'), get_the_author())), get_the_author());
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
if (is_singular()) {
if ($tag_list) {
$utility_text = __('<span class="post-date">%3$s</span><span class="post-categories">%1$s</span><span class="post-tags">%2$s</span><span class="post-author"> by %4$s</span>', 'tokopress');
} elseif ($categories_list) {
$utility_text = __('<span class="post-date">%3$s</span><span class="post-categories">%1$s</span><span class="post-author"> by %4$s</span>', 'tokopress');
} else {
$utility_text = __('<span class="post-date">%3$s</span><span class="post-author"> by %4$s</span>', 'tokopress');
}
} else {
if ($categories_list) {
$utility_text = __('<span class="post-date">%3$s</span><span class="post-categories">%1$s</span><span class="post-author"> by %4$s</span>', 'tokopress');
} else {
$utility_text = __('<span class="post-date">%3$s</span><span class="by-author"> by %4$s</span>', 'tokopress');
}
}
printf($utility_text, $categories_list, $tag_list, $date, $author);
}
示例15: pinnacle_title
/**
* Page titles
*/
function pinnacle_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
} else {
return __('Latest Posts', 'pinnacle');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
return $term->name;
} elseif (is_post_type_archive()) {
return get_queried_object()->labels->name;
} elseif (is_day()) {
return sprintf(__('Daily Archives: %s', 'pinnacle'), get_the_date());
} elseif (is_month()) {
return sprintf(__('Monthly Archives: %s', 'pinnacle'), get_the_date('F Y'));
} elseif (is_year()) {
return sprintf(__('Yearly Archives: %s', 'pinnacle'), get_the_date('Y'));
} elseif (is_author()) {
return sprintf(__('Author Archives: %s', 'pinnacle'), get_the_author());
} else {
return single_cat_title("", false);
}
} elseif (is_search()) {
return sprintf(__('Search Results for %s', 'pinnacle'), get_search_query());
} elseif (is_404()) {
return __('Not Found', 'pinnacle');
} else {
return get_the_title();
}
}