本文整理汇总了PHP中get_the_date函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_date函数的具体用法?PHP get_the_date怎么用?PHP get_the_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_date函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
function widget($args, $instance)
{
global $post;
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
while ($posts->have_posts()) {
$posts->the_post();
// Insert post date if needed.
if ($instance['postdate'] == 'on') {
$date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
}
// HTML output
echo '<div class="recent-posts">';
if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
} else {
echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
}
echo '</div>';
}
wp_reset_query();
echo $after_widget;
}
示例2: 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;
}
示例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: distinctpress_post_date
/** DistinctPress Post Date */
function distinctpress_post_date()
{
$post_date = esc_html(get_the_date()) . " " . esc_attr(get_the_time());
/** Output */
$output = sprintf('<span class="entry-date" title="%1$s"><a href="%2$s" title="%3$s" rel="bookmark"><i class="el-icon-time-alt meta-icon"></i>%1$s</a></span>', $post_date, esc_url(get_permalink()), the_title_attribute('echo=0'));
return $output;
}
示例5: ultra_posted_on
/**
* Prints HTML with meta information for the current post-date/time, author, comment count and categories.
*/
function ultra_posted_on()
{
echo '<div class="entry-meta-inner">';
if (is_sticky() && is_home() && !is_paged()) {
echo '<span class="featured-post">' . __('Sticky', 'ultra') . '</span>';
}
if (is_home() && siteorigin_setting('blog_post_date') || is_archive() && siteorigin_setting('blog_post_date') || is_search() && siteorigin_setting('blog_post_date')) {
echo '<span class="entry-date"><a href="' . esc_url(get_permalink()) . '" rel="bookmark"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span></a>';
}
if (is_single() && siteorigin_setting('blog_post_date')) {
echo '<span class="entry-date"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span>';
}
if (siteorigin_setting('blog_post_author')) {
echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author">' . esc_html(get_the_author()) . '</a></span></span>';
}
if (comments_open() && siteorigin_setting('blog_post_comment_count')) {
echo '<span class="comments-link">';
comments_popup_link(__('Leave a comment', 'ultra'), __('1 Comment', 'ultra'), __('% Comments', 'ultra'));
echo '</span>';
}
echo '</div>';
if (is_single() && siteorigin_setting('navigation_post_nav')) {
the_post_navigation($args = array('prev_text' => '', 'next_text' => ''));
}
}
示例6: appointment_aside_meta_content
function appointment_aside_meta_content()
{
$appointment_options = theme_setup_data();
$news_setting = wp_parse_args(get_option('appointment_options', array()), $appointment_options);
if ($news_setting['home_meta_section_settings'] == '') {
?>
<!--show date of post-->
<aside class="blog-post-date-area">
<div class="date"><?php
echo get_the_date('j');
?>
<div class="month-year"><?php
echo get_the_date('M');
?>
,<?php
echo get_the_date('Y');
?>
</div></div>
<div class="comment"><a href="<?php
the_permalink();
?>
"><i class="fa fa-comments"></i><?php
comments_number('0', '1', '%');
?>
</a></div>
</aside>
<?php
}
}
示例7: 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;
}
示例8: oxy_shortcode_recent
function oxy_shortcode_recent($atts, $content = '')
{
// setup options
extract(shortcode_atts(array('count' => 4, 'categories' => null, 'authors' => null, 'post_formats' => null, 'titles' => 'show'), $atts));
$categories = null === $categories ? null : explode(',', $categories);
$authors = null === $authors ? null : explode(',', $authors);
$post_formats = null === $post_formats ? null : explode(',', $post_formats);
$posts = oxy_get_recent_posts($count, $categories, $authors, $post_formats);
$output = '';
if (!empty($posts)) {
$output .= '[raw]<ul class="oxyrecentposts">';
global $post;
foreach ($posts as $post) {
setup_postdata($post);
$output .= '<li>';
$output .= '<a href="' . get_permalink() . '" class="recent-feature" >';
if (has_post_thumbnail($post->ID)) {
$output .= get_the_post_thumbnail($post->ID, array(64, 64), array('title' => $post->post_title, 'alt' => $post->post_title));
} else {
// $output .= oxy_theme_icon( oxy_get_post_icon( $post->ID ), 'span' );
}
$output .= '</a>';
if ('show' == $titles) {
$output .= '<h5>' . get_the_title($post->ID) . '</h5>';
$output .= '<p>' . get_the_date() . '</p>';
}
$output .= '</li>';
}
$output .= '</ul>[/raw]';
}
// reset post data
wp_reset_postdata();
return $output;
}
示例9: ago
static function ago()
{
$date = time() - strtotime(get_the_date("Y/n/j H:i:s", get_the_ID()));
$date = intval($date / 60);
//Mins
$verb = $date == 1 ? "min" : "mins";
if ($date > 60) {
$date = intval($date / 60);
//Hours
$verb = $date == 1 ? "hour" : "hours";
if ($date > 24) {
$date = intval($date / 24);
//Days
$verb = $date == 1 ? "day" : "days";
if ($date > 30) {
$days = $date;
$date = intval($date / 30);
//Months
$verb = $date == 1 ? "month" : "months";
if ($date > 12) {
$date = intval($days / 365);
//Years
$verb = $date == 1 ? "year" : "years";
}
}
}
}
return $date . " " . $verb . " ago";
}
示例10: header_meta
function header_meta()
{
?>
<div class="post-date">
<time datetime="<?php
echo get_the_date('c');
?>
" pubdate>
<span>
<?php
echo get_the_date('M');
?>
</span>
<span>
<?php
echo get_the_date('d');
?>
</span>
<span>
<?php
echo get_the_date('Y');
?>
</span>
</time>
</div><!-- /.entry-meta -->
<?php
}
示例11: swv_default_title
function swv_default_title($title)
{
if (empty($title) && in_array(get_post_type(), array('post', 'page', 'attachment'))) {
$title = get_the_date();
}
return $title;
}
示例12: jkl_index_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function jkl_index_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()));
$byline = sprintf(esc_html('%s'), '<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 ('chat' === get_post_format() || 'image' === get_post_format() || 'gallery' === get_post_format() || 'audio' === get_post_format() || 'video' === get_post_format()) {
$string = ucwords(get_post_format());
$posted_on = $string . ': <a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>';
} else {
$posted_on = sprintf(esc_html_x('Date: %s', 'post date', 'jkl'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
}
$meta_class = is_single() ? 'format-small-meta' : 'meta-content-index';
echo '<div class="' . $meta_class . '">';
echo '<span class="posted-on">' . $posted_on . '</span>';
// WPCS: XSS OK.
if (is_single()) {
echo '<span class="byline">' . $byline . '</span>';
if (!has_post_format('quote')) {
jkl_better_taxonomy_listing('category', 1);
}
}
echo '</div><!-- .meta-content-index -->';
}
示例13: 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();
}
}
示例14: corenominal_shortcode_loop_tag
/**
* Loop tag
* Shows posts for a given tag
* Usage: [corenominal-loop-tag tag=foo per_page=30]
*/
function corenominal_shortcode_loop_tag($atts, $content = null)
{
$atts = shortcode_atts(array('tag' => 'foo', 'per_page' => 30), $atts);
// WP_Query arguments
$args = array('post_type' => array('post'), 'post_status' => array('publish'), 'tag' => $atts['tag'], 'posts_per_page' => $atts['per_page'], 'order' => 'DESC');
// The Query
$query = new WP_Query($args);
$data = '';
if ($query->have_posts()) {
$data .= '<h3>Related Posts</h3>';
$data .= '<ul class="related-posts">';
while ($query->have_posts()) {
$query->the_post();
$data .= '<li>';
$data .= '<span>' . get_the_date('Y-m-d') . '</span> ';
$data .= '<a href="' . get_the_permalink() . '">';
$data .= get_the_title();
$data .= '</a>';
$data .= '</li>';
}
$data .= '</ul>';
}
wp_reset_postdata();
return $data;
}
示例15: airballoon_display_postmeta
function airballoon_display_postmeta()
{
?>
<span class="meta-date">
<?php
printf('<a href="%1$s" title="%2$s" rel="bookmark"><time 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()));
?>
</span>
<span class="meta-author">
<?php
printf('<a href="%1$s" title="%2$s" rel="author">%3$s</a>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'airballoon-lite'), get_the_author())), get_the_author());
?>
</span>
<?php
if (comments_open()) {
?>
<span class="meta-comments">
<?php
comments_popup_link(__('Leave a comment', 'airballoon-lite'), __('One comment', 'airballoon-lite'), __('% comments', 'airballoon-lite'));
?>
</span>
<?php
}
edit_post_link(__('Edit Post', 'airballoon-lite'));
}