本文整理汇总了PHP中get_the_time函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_time函数的具体用法?PHP get_the_time怎么用?PHP get_the_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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.
}
示例2: get_index_headline
function get_index_headline()
{
if (is_home()) {
$index_headline = 'Blog Index';
} else {
if (is_category()) {
$category = single_term_title("", false);
$index_headline = 'Archives for the "' . $category . '" Category';
} elseif (is_tag()) {
$tag = single_term_title("", false);
$index_headline = 'Archives for the "' . $tag . '" Category';
} elseif (is_day()) {
$index_headline = 'Archive for ' . get_the_time('F jS, Y');
} elseif (is_month()) {
$index_headline = 'Archive for ' . get_the_time('F Y');
} elseif (is_year()) {
$index_headline = 'Archive for ' . get_the_time('Y');
} elseif (is_author()) {
$index_headline = 'Author Archive';
} else {
$index_headline = 'Blog Archives';
}
}
return $index_headline;
}
示例3: thirdrail_entry_meta
function thirdrail_entry_meta()
{
echo '<div class="entry-meta">';
echo '<p class="byline"><a href="' . get_author_posts_url(get_the_author_meta('ID')) . '" rel="author" class="author">' . get_the_author() . '</a>' . cats() . '</p>';
echo '<time class="updated date" datetime="' . get_the_time('c') . '">' . sprintf(__('%s', 'thirdrail'), get_the_date()) . '</time>';
echo '</div>';
}
示例4: 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;
}
示例5: genesis_post_time_shortcode
function genesis_post_time_shortcode($atts)
{
$defaults = array('format' => get_option('time_format'), 'before' => '', 'after' => '', 'label' => '');
$atts = shortcode_atts($defaults, $atts);
$output = sprintf('<span class="time published" title="%5$s">%1$s%3$s%4$s%2$s</span> ', $atts['before'], $atts['after'], $atts['label'], get_the_time($atts['format']), get_the_time('Y-m-d\\TH:i:sO'));
return apply_filters('genesis_post_time_shortcode', $output, $atts);
}
示例6: appletree_post_meta
/**
* Displays meta information for a post
* @return void
*/
function appletree_post_meta()
{
if (get_post_type() == 'post') {
echo sprintf(__('Posted %s in %s%s by %s. ', 'appletreesg.com'), get_the_time(get_option('date_format')), get_the_category_list(', '), get_the_tag_list(__(', <b>Tags</b>: ', 'appletreesg.com'), ', '), get_the_author_link());
}
edit_post_link(__(' (edit)', 'appletreesg.com'), '<span class="edit-link">', '</span>');
}
示例7: end_el
function end_el(&$output, $item, $depth = 0, $args = array())
{
if ($depth == 0 && $item->object == 'category') {
$output .= "<div class='subcat'>";
for ($i = 0; $i < count($item->children); $i++) {
$child = $item->children[$i];
$output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
//$output .="<h5>".$child->title."</h5>";
$output .= "<ul id='mn-latest-" . $child->ID . "'>";
if ($child->object == 'category') {
$r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
if ($r->have_posts()) {
while ($r->have_posts()) {
$r->the_post();
$output .= "<li ";
if (has_post_thumbnail()) {
$output .= "class='has-thumbnail' ";
}
$output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
}
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
}
}
$output .= "</ul>";
$output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
$output .= "</div>";
}
$output .= "</div> \n</div>\n";
} else {
}
$output .= "</li>\n";
}
示例8: __construct
/**
* Get things started
*
* @access public
* @since 2.7
* @return void/
*/
public function __construct($sub_id)
{
global $ninja_forms_fields;
// Bail if the sub doesn't exist.
$sub = get_post($sub_id);
if (!is_object($sub)) {
return false;
}
// Set our sub id
$this->sub_id = $sub_id;
// Populate our fields
$this->fields = array();
$this->retrieve_fields();
// Setup our form id var
$this->form_id = $this->get_meta('_form_id');
// Setup our action var
$this->action = $this->get_meta('_action');
// Setup our sequential id
$this->seq_num = $this->get_meta('_seq_num');
// Setup our user_id var
$this->user_id = $sub->post_author;
// Setup our date submitted var
$this->date_submitted = get_the_time('Y-m-d G:i:s', $sub_id);
// Setup our date modified var
$this->date_modified = get_post_modified_time('Y-m-d G:i:s', false, $sub_id);
}
示例9: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
$instance = wp_parse_args($instance, array('title' => __('Latest Questions', 'dwqa'), 'number' => 5));
echo $before_widget;
echo $before_title;
echo $instance['title'];
echo $after_title;
$args = array('posts_per_page' => $instance['number'], 'order' => 'DESC', 'orderby' => 'post_date', 'post_type' => 'dwqa-question', 'suppress_filters' => false);
$questions = new WP_Query($args);
if ($questions->have_posts()) {
echo '<div class="dwqa-popular-questions">';
echo '<ul>';
while ($questions->have_posts()) {
$questions->the_post();
echo '
<li><a href="' . get_permalink() . '" class="question-title">' . get_the_title() . '</a> ' . __('asked by', 'dwqa') . ' ' . (dwqa_is_anonymous(get_the_ID()) ? __('Anonymous', 'dwqa') : get_the_author_link()) . ', ' . human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago';
'</li>';
}
echo '</ul>';
echo '</div>';
}
wp_reset_query();
wp_reset_postdata();
echo $after_widget;
}
示例10: twentyten_posted_on
function twentyten_posted_on()
{
$meta = array();
$meta['author'] = sprintf(__('%1$s <span class="meta-sep">by</span> %2$s', 'wordcampbase'), sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>', get_permalink(), esc_attr(get_the_time()), get_the_date()), sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', get_author_posts_url(get_the_author_meta('ID')), sprintf(esc_attr__('View all posts by %s', 'wordcampbase'), get_the_author()), get_the_author()));
$meta['sep'] = ' <span class="meta-sep meta-sep-bull">•</span> ';
$meta['comments'] = array('before' => '<span class="comments-link">', 'after' => '</span>', 'zero' => __('Leave a comment', 'wordcampbase'), 'one' => __('1 Comment', 'wordcampbase'), 'many' => __('% Comments', 'wordcampbase'));
$meta['edit'] = array('title' => __('Edit', 'wordcampbase'), 'before' => '<span class="edit-link">', 'after' => '</span>');
$meta['br'] = '<br />';
// Just to have.
$meta['order'] = array('author', 'sep', 'comments', 'edit');
$meta = apply_filters('wcb_entry_meta', $meta);
if (!is_array($meta) || !isset($meta['order'])) {
return;
}
foreach ($meta['order'] as $type) {
$content = $meta[$type];
switch ($type) {
case 'comments':
echo $content['before'];
comments_popup_link($content['zero'], $content['one'], $content['many']);
echo $content['after'];
break;
case 'edit':
if (isset($meta['sep'])) {
$content['before'] = $meta['sep'] . $content['before'];
}
edit_post_link($content['title'], $content['before'], $content['after']);
break;
default:
echo $content;
}
}
}
示例11: material_design_par_amauri_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function material_design_par_amauri_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__('Posted on %s', 'material-design-par-amauri'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
$byline = sprintf(esc_html__('by %s', 'material-design-par-amauri'), '<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>');
if (is_singular()) {
echo '<img width="36" height="36" src="' . esc_url(get_template_directory_uri() . '/image/icon/_' . get_post_format() . '.png') . '" alt="' . get_post_format() . '" /> ';
}
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span> ';
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__(', ', 'material-design-par-amauri'));
if ($categories_list && material_design_par_amauri_categorized_blog()) {
printf('<span class="cat-links">' . esc_html__('in %1$s', 'material-design-par-amauri') . '</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__(', ', 'material-design-par-amauri'));
if ($tags_list) {
printf('<span class="tags-links">' . esc_html__(', tagged: %1$s', 'material-design-par-amauri') . '</span>', $tags_list);
// WPCS: XSS OK.
}
}
}
示例12: __construct
public function __construct($post = null)
{
if (!empty($post) && ($post = get_post($post))) {
$this->id = $post->ID;
$this->date = get_the_time(__('Y/m/d g:i:s A', 'flamingo'), $this->id);
$this->subject = get_post_meta($post->ID, '_subject', true);
$this->from = get_post_meta($post->ID, '_from', true);
$this->from_name = get_post_meta($post->ID, '_from_name', true);
$this->from_email = get_post_meta($post->ID, '_from_email', true);
$this->fields = get_post_meta($post->ID, '_fields', true);
foreach ($this->fields as $key => $value) {
$meta_key = sanitize_key('_field_' . $key);
if (metadata_exists('post', $post->ID, $meta_key)) {
$value = get_post_meta($post->ID, $meta_key, true);
$this->fields[$key] = $value;
}
}
$this->meta = get_post_meta($post->ID, '_meta', true);
$this->akismet = get_post_meta($post->ID, '_akismet', true);
$terms = wp_get_object_terms($this->id, self::channel_taxonomy);
if (!empty($terms) && !is_wp_error($terms)) {
$this->channel = $terms[0]->slug;
}
if (self::spam_status == get_post_status($post)) {
$this->spam = true;
} else {
$this->spam = !empty($this->akismet['spam']);
}
}
}
示例13: ar2_posted_on
/**
* @todo
* Function adapted from http://graveyard.maniacalrage.net/etc/relative/.
* @since 1.6
*/
function ar2_posted_on($echo = 1)
{
$result = '';
if (!ar2_get_theme_option('relative_dates')) {
$result = sprintf(__('%s', 'ar2'), get_the_time(get_option('date_format')));
} else {
$diff = current_time('timestamp') - get_the_time('U');
$months = floor($diff / 2592000);
$diff -= $months * 2419200;
$weeks = floor($diff / 604800);
$diff -= $weeks * 604800;
$days = floor($diff / 86400);
$diff -= $days * 86400;
$hours = floor($diff / 3600);
$diff -= $hours * 3600;
$minutes = floor($diff / 60);
$diff -= $minutes * 60;
if ($months > 0 || $months < 0) {
// over a month old, just show date
$result = sprintf(__('on %s', 'ar2'), get_the_time(get_option('date_format')));
} else {
if ($weeks > 0) {
// weeks
if ($weeks > 1) {
$result = sprintf(__('%s weeks ago', 'ar2'), number_format_i18n($weeks));
} else {
$result = __('1 week ago', 'ar2');
}
} elseif ($days > 0) {
// days
if ($days > 1) {
$result = sprintf(__('%s days ago', 'ar2'), number_format_i18n($days));
} else {
$result = __('1 day ago', 'ar2');
}
} elseif ($hours > 0) {
// hours
if ($hours > 1) {
$result = sprintf(__('%s hours ago', 'ar2'), number_format_i18n($hours));
} else {
$result = __('1 hour ago', 'ar2');
}
} elseif ($minutes > 0) {
// minutes
if ($minutes > 1) {
$result = sprintf(__('%s minutes ago', 'ar2'), number_format_i18n($minutes));
} else {
$result = __('1 minute ago', 'ar2');
}
} else {
// seconds
$result = __('less than a minute ago', 'ar2');
}
}
}
if ($echo) {
echo $result;
}
return $result;
}
示例14: beans_post_meta_date_shortcode
/**
* Echo post meta date shortcode.
*
* @since 1.0.0
*/
function beans_post_meta_date_shortcode()
{
echo beans_output('beans_post_meta_date_prefix', __('Posted on ', 'beans'));
echo beans_open_markup('beans_post_meta_date', 'time', array('datetime' => get_the_time('c')));
echo beans_output('beans_post_meta_date_text', get_the_time(get_option('date_format')));
echo beans_close_markup('beans_post_meta_date', 'time');
}
示例15: 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>';
}
}