本文整理汇总了PHP中get_archives_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_archives_link函数的具体用法?PHP get_archives_link怎么用?PHP get_archives_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_archives_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_get_archives_link
function smarty_get_archives_link($params)
{
$format = 'html';
$before = '';
$after = '';
extract($params);
return get_archives_link($url, $text, $format, $before, $after);
}
示例2: get_blix_archive
function get_blix_archive($show_comment_count = 0, $before = '<h4>', $after = '</h4>', $year = 0, $post_type = 'post', $limit = 100)
{
global $month, $wpdb;
$result = '';
if ($year) {
$AND_year = " AND YEAR(post_date)='{$year}'";
}
if ($limit) {
$LIMIT = " LIMIT {$limit}";
}
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_type='{$post_type}' {$AND_year} AND post_status='publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
if ($arcresults) {
foreach ($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
$text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
$result .= get_archives_link($url, $text, '', $before, $after);
$thismonth = zeroise($arcresult->month, 2);
$thisyear = $arcresult->year;
$arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status, guid, comment_count FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_type='{$post_type}' AND post_password='' ORDER BY post_date DESC {$LIMIT}");
if ($arcresults2) {
$result .= "<ul class=\"postspermonth\">\n";
foreach ($arcresults2 as $arcresult2) {
if ($arcresult2->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult2->ID);
//$arcresult2->guid;
$arc_title = $arcresult2->post_title;
if ($arc_title) {
$text = strip_tags($arc_title);
} else {
$text = $arcresult2->ID;
}
$result .= "<li>" . get_archives_link($url, $text, '');
if ($show_comment_count) {
$cc = $arcresult2->comment_count;
if ($arcresult2->comment_status == "open" or $comments_count > 0) {
$result .= " ({$cc})";
}
}
$result .= "</li>\n";
}
}
$result .= "</ul>\n";
}
}
}
return $result;
}
示例3: dt_archives_shortcode
function dt_archives_shortcode()
{
global $month, $wpdb, $wp_version;
// a mysql query to get the list of distinct years and months that posts have been created
$sql = 'SELECT
DISTINCT YEAR(post_date) AS year,
MONTH(post_date) AS month,
count(ID) as posts
FROM ' . $wpdb->posts . '
WHERE post_status="publish"
AND post_type="post"
AND post_password=""
GROUP BY YEAR(post_date),
MONTH(post_date)
ORDER BY post_date DESC';
// use get_results to do a query directly on the database
$archiveSummary = $wpdb->get_results($sql);
// if there are any posts
if ($archiveSummary) {
$output = '<div class="archives">';
// loop through the posts
foreach ($archiveSummary as $date) {
// reset the query variable
unset($bmWp);
// create a new query variable for the current month and year combination
$bmWp = new WP_Query('year=' . $date->year . '&monthnum=' . zeroise($date->month, 2) . '&posts_per_page=-1');
// if there are any posts for that month display them
if ($bmWp->have_posts()) {
// display the archives heading
$url = get_month_link($date->year, $date->month);
$text = $month[zeroise($date->month, 2)] . ' ' . $date->year;
$output .= get_archives_link($url, $text, '', '<h3>', '</h3>');
$output .= '<ul class="postspermonth">';
// display an unordered list of posts for the current month
while ($bmWp->have_posts()) {
$bmWp->the_post();
$output .= '<li><a href="' . get_permalink($bmWp->post) . '" title="' . esc_html($text, 1) . '">' . wptexturize($bmWp->post->post_title) . '</a></li>';
}
$output .= '</ul>';
}
}
$output .= '</div><!-- .archives -->';
return $output;
}
}
示例4: BX_archive
/**
* Function BX_archive
* ------------------------------------------------------
* This function is based on WP's built-in get_archives()
* It outputs the following:
*
* <h3><a href="link">Month Year</a></h3>
* <ul class="postspermonth">
* <li><a href="link">Post title</a> (Comment count)</li>
* [..]
* </ul>
*/
function BX_archive()
{
global $month, $wpdb;
$now = current_time('mysql');
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_date <'" . $now . "' AND post_status='publish' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
if ($arcresults) {
foreach ($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
$text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
echo get_archives_link($url, $text, '', '<h3>', '</h3>');
$thismonth = zeroise($arcresult->month, 2);
$thisyear = $arcresult->year;
$arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_password='' ORDER BY post_date DESC");
if ($arcresults2) {
echo "<ul class=\"postspermonth\">\n";
foreach ($arcresults2 as $arcresult2) {
if ($arcresult2->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult2->ID);
$arc_title = $arcresult2->post_title;
if ($arc_title) {
$text = strip_tags($arc_title);
} else {
$text = $arcresult2->ID;
}
echo "<li>" . get_archives_link($url, $text, '');
$comments = mysql_query("SELECT * FROM " . $wpdb->comments . " WHERE comment_post_ID=" . $arcresult2->ID);
$comments_count = mysql_num_rows($comments);
if ($arcresult2->comment_status == "open" or $comments_count > 0) {
echo ' (' . $comments_count . ')';
}
echo "</li>\n";
}
}
echo "</ul>\n";
}
}
}
}
示例5: wp_custom_archive
function wp_custom_archive($args = '')
{
global $wpdb, $wp_locale;
$defaults = array('limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if ('' != $limit) {
$limit = absint($limit);
$limit = ' LIMIT ' . $limit;
}
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) {
$archive_day_date_format = get_option('date_format');
$archive_week_start_date_format = get_option('date_format');
$archive_week_end_date_format = get_option('date_format');
}
//filters
$where = apply_filters('customarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r);
$join = apply_filters('customarchives_join', "", $r);
$output = '<ul>';
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC {$limit}";
$key = md5($query);
$cache = wp_cache_get('wp_custom_archive', 'general');
if (!isset($cache[$key])) {
$arcresults = $wpdb->get_results($query);
$cache[$key] = $arcresults;
wp_cache_set('wp_custom_archive', $cache, 'general');
} else {
$arcresults = $cache[$key];
}
if ($arcresults) {
$afterafter = $after;
foreach ((array) $arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
/* translators: 1: month name, 2: 4-digit year */
$text = sprintf(__('%s'), $wp_locale->get_month($arcresult->month));
$year_text = sprintf('<li>%d</li>', $arcresult->year);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
$output .= $arcresult->year != $temp_year ? $year_text : '';
$output .= get_archives_link($url, $text, $format, $before, $after);
$temp_year = $arcresult->year;
}
}
$output .= '</ul>';
if ($echo) {
echo $output;
} else {
return $output;
}
}
示例6: do_week_archive_items
/**
* Adds the items to the trail items array for week archives.
*
* @since 0.6.0
* @access public
* @return void
*/
public function do_week_archive_items()
{
/* Add $wp_rewrite->front to the trail. */
$this->do_rewrite_front_items();
/* Get the year and week. */
$year = get_the_time($this->args['labels']['archive_year']);
$week = sprintf($this->args['labels']['archive_week'], date_i18n('W', get_the_time('U')));
/* Add the year item. */
$this->items[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . esc_attr($year) . '" rel="v:url" property="v:title">' . $year . '</a>';
/* Add the week item. */
if (is_paged()) {
$this->items[] = get_archives_link(add_query_arg(array('m' => get_the_time('Y'), 'w' => get_the_time('W')), home_url()), $week, false);
} elseif (true === $this->args['show_title']) {
$this->items[] = $week;
}
}
示例7: get_archives
function get_archives($type = '', $limit = '', $format = 'html', $before = "", $after = "", $show_post_count = false)
{
global $dateformat, $time_difference, $siteurl, $wp_id;
global $month, $wpdb, $wp_month_format;
if ('' == $type) {
$type = get_settings('archive_mode');
}
if ('' != $limit) {
$limit = (int) $limit;
$limit = " LIMIT {$limit}";
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–';
// archive link url
$archive_link_m = $siteurl . '/index.php?m=';
# monthly archive;
$archive_link_w = $siteurl . '/index.php?w=';
# weekly archive;
$archive_link_p = $siteurl . '/index.php?p=';
# post-by-post archive;
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) {
$archive_day_date_format = $dateformat;
$archive_week_start_date_format = $dateformat;
$archive_week_end_date_format = $dateformat;
}
$now = date('Y-m-d H:i:s', time() + $time_difference * 3600);
if ('monthly' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts[$wp_id]} WHERE post_date < '{$now}' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
if ($arcresults) {
foreach ($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
if ($show_post_count) {
$text = ereg_replace('%MONTH', $month[zeroise($arcresult->month, 2)], $wp_month_format);
$text = ereg_replace('%YEAR', sprintf("%d", $arcresult->year), $text);
$after = " ({$arcresult->posts})";
} else {
$text = ereg_replace('%MONTH', $month[zeroise($arcresult->month, 2)], $wp_month_format);
$text = ereg_replace('%YEAR', sprintf("%d", $arcresult->year), $text);
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('daily' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM {$wpdb->posts[$wp_id]} WHERE post_date < '{$now}' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
if ($arcresults) {
foreach ($arcresults as $arcresult) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date);
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('weekly' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, " . get_settings('start_of_week') . ") AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM {$wpdb->posts[$wp_id]} WHERE post_date < '{$now}' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
$arc_w_last = '';
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->week != $arc_w_last) {
$arc_year = $arcresult->yr;
$arc_w_last = $arcresult->week;
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
$url = sprintf("%s/index.php?m=%s&w=%d", $siteurl, $arc_year, $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
echo get_archives_link($url, $text, $format, $before, $after);
}
}
}
} elseif ('postbypost' == $type) {
$arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM {$wpdb->posts[$wp_id]} WHERE post_date < '{$now}' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult->ID);
$arc_title = stripslashes($arcresult->post_title);
if ($arc_title) {
$text = strip_tags($arc_title);
} else {
$text = $arcresult->ID;
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
}
}
}
示例8: wp_get_archives
/**
* Display archive links based on type and format.
*
* The 'type' argument offers a few choices and by default will display monthly
* archive links. The other options for values are 'daily', 'weekly', 'monthly',
* 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
* same archive link list, the difference between the two is that 'alpha'
* will order by post title and 'postbypost' will order by post date.
*
* The date archives will logically display dates with links to the archive post
* page. The 'postbypost' and 'alpha' values for 'type' argument will display
* the post titles.
*
* The 'limit' argument will only display a limited amount of links, specified
* by the 'limit' integer value. By default, there is no limit. The
* 'show_post_count' argument will show how many posts are within the archive.
* By default, the 'show_post_count' argument is set to false.
*
* For the 'format', 'before', and 'after' arguments, see {@link
* get_archives_link()}. The values of these arguments have to do with that
* function.
*
* @since 1.2.0
*
* @param string|array $args Optional. Override defaults.
*/
function wp_get_archives($args = '')
{
global $wpdb, $wp_locale;
$defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1);
$r = wp_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
if ('' == $type) {
$type = 'monthly';
}
if ('' != $limit) {
$limit = absint($limit);
$limit = ' LIMIT ' . $limit;
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–';
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) {
$archive_day_date_format = get_option('date_format');
$archive_week_start_date_format = get_option('date_format');
$archive_week_end_date_format = get_option('date_format');
}
//filters
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r);
$join = apply_filters('getarchives_join', '', $r);
$output = '';
if ('monthly' == $type) {
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC {$limit}";
$key = md5($query);
$cache = wp_cache_get('wp_get_archives', 'general');
if (!isset($cache[$key])) {
$arcresults = $wpdb->get_results($query);
$cache[$key] = $arcresults;
wp_cache_set('wp_get_archives', $cache, 'general');
} else {
$arcresults = $cache[$key];
}
if ($arcresults) {
$afterafter = $after;
foreach ((array) $arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
/* translators: 1: month name, 2: 4-digit year */
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
$output .= get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('yearly' == $type) {
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date) ORDER BY post_date DESC {$limit}";
$key = md5($query);
$cache = wp_cache_get('wp_get_archives', 'general');
if (!isset($cache[$key])) {
$arcresults = $wpdb->get_results($query);
$cache[$key] = $arcresults;
wp_cache_set('wp_get_archives', $cache, 'general');
} else {
$arcresults = $cache[$key];
}
if ($arcresults) {
$afterafter = $after;
foreach ((array) $arcresults as $arcresult) {
$url = get_year_link($arcresult->year);
$text = sprintf('%d', $arcresult->year);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
$output .= get_archives_link($url, $text, $format, $before, $after);
//.........这里部分代码省略.........
示例9: tc_breadcrumb_trail_get_items
//.........这里部分代码省略.........
/* If $front has been set, add it to the $path. */
if ($post_type_object->rewrite['with_front'] && $wp_rewrite->front) {
$path .= trailingslashit($wp_rewrite->front);
}
/* If there's a slug, add it to the $path. */
if (!empty($post_type_object->rewrite['slug'])) {
$path .= $post_type_object->rewrite['slug'];
}
/* If there's a path, check for parents. */
if (!empty($path)) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
}
/* Add the post type [plural] name to the trail end. */
if (is_paged()) {
$trail[] = '<a href="' . esc_url(get_post_type_archive_link($post_type_object->name)) . '" title="' . esc_attr(post_type_archive_title('', false)) . '">' . post_type_archive_title('', false) . '</a>';
} else {
$trail[] = post_type_archive_title('', false);
}
} elseif (is_author()) {
/* Get the user ID. */
$user_id = get_query_var('author');
/* If $front has been set, add it to $path. */
if (!empty($wp_rewrite->front)) {
$path .= trailingslashit($wp_rewrite->front);
}
/* If an $author_base exists, add it to $path. */
if (!empty($wp_rewrite->author_base)) {
$path .= $wp_rewrite->author_base;
}
/* If $path exists, check for parent pages. */
if (!empty($path)) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $path));
}
/* Add the author's display name to the trail end. */
if (is_paged()) {
$trail[] = '<a href="' . esc_url(get_author_posts_url($user_id)) . '" title="' . esc_attr(get_the_author_meta('display_name', $user_id)) . '">' . get_the_author_meta('display_name', $user_id) . '</a>';
} else {
$trail[] = get_the_author_meta('display_name', $user_id);
}
} elseif (is_time()) {
if (get_query_var('minute') && get_query_var('hour')) {
$trail[] = get_the_time(__('g:i a', 'breadcrumb-trail'));
} elseif (get_query_var('minute')) {
$trail[] = sprintf(__('Minute %1$s', 'breadcrumb-trail'), get_the_time(__('i', 'breadcrumb-trail')));
} elseif (get_query_var('hour')) {
$trail[] = get_the_time(__('g a', 'breadcrumb-trail'));
}
} elseif (is_date()) {
/* If $front has been set, check for parent pages. */
if ($wp_rewrite->front) {
$trail = array_merge($trail, tc_breadcrumb_trail_get_parents('', $wp_rewrite->front));
}
if (is_day()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
$trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = '<a href="' . get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" title="' . get_the_time(esc_attr__('d', 'breadcrumb-trail')) . '">' . get_the_time(__('d', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('d', 'breadcrumb-trail'));
}
} elseif (get_query_var('w')) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = get_archives_link(add_query_arg(array('m' => get_the_time('Y'), 'w' => get_the_time('W')), esc_url(home_url())), sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail'))), false);
} else {
$trail[] = sprintf(__('Week %1$s', 'breadcrumb-trail'), get_the_time(esc_attr__('W', 'breadcrumb-trail')));
}
} elseif (is_month()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', 'breadcrumb-trail')) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
if (is_paged()) {
$trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', 'breadcrumb-trail')) . '">' . get_the_time(__('F', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('F', 'breadcrumb-trail'));
}
} elseif (is_year()) {
if (is_paged()) {
$trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . esc_attr(get_the_time(__('Y', 'breadcrumb-trail'))) . '">' . get_the_time(__('Y', 'breadcrumb-trail')) . '</a>';
} else {
$trail[] = get_the_time(__('Y', 'breadcrumb-trail'));
}
}
}
} elseif (is_search()) {
if (is_paged()) {
$trail[] = '<a href="' . get_search_link() . '" title="' . sprintf(esc_attr__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query())) . '">' . sprintf(__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query())) . '</a>';
} else {
$trail[] = sprintf(__('Search results for "%1$s"', 'breadcrumb-trail'), esc_attr(get_search_query()));
}
} elseif (is_404()) {
$trail[] = __('404 Not Found', 'breadcrumb-trail');
}
/* Check for pagination. */
if (is_paged()) {
$trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('paged')));
} elseif (is_singular() && 1 < get_query_var('page')) {
$trail[] = sprintf(__('Page %d', 'breadcrumb-trail'), absint(get_query_var('page')));
}
/* Allow devs to step in and filter the $trail array. */
return apply_filters('breadcrumb_trail_items', $trail, $args);
}
示例10: echo_marchive
function echo_marchive($old_date, $format, $before, $count, $show_post_count)
{
global $persian_month_names;
$year = substr($old_date, 0, 4);
$month = substr($old_date, 4, 2);
if ($show_post_count) {
$count = ' (' . fixnumber($count) . ')';
} else {
$count = '';
}
echo get_archives_link(get_month_link($year, $month), $persian_month_names[intval($month)] . ' ' . fixnumber($year), $format, $before, $count);
}
示例11: foreach
$items = '';
foreach ($archives as $archive) {
// Build URL
$url = ctc_post_type_get_month_link($archive->year, $archive->month, $instance['post_type']);
// Format of link text
/* translators: 1: month name, 2: 4-digit year */
$text = sprintf(_x('%1$s %2$d', 'archives widget', 'uplifted'), $wp_locale->get_month($archive->month), $archive->year);
// Show count after link?
$after = '';
if (!empty($instance['show_count'])) {
// show count
$after = ' (' . $archive->posts . ')';
}
// Month item
$format = 'html';
// list link
if (!empty($instance['show_dropdown'])) {
$format = 'option';
// dropdown option
}
$items .= get_archives_link($url, $text, $format, '', $after);
}
// Show as dropdown
if (!empty($instance['show_dropdown'])) {
echo '<form>';
echo ' <select onchange="document.location.href=this.options[this.selectedIndex].value;">';
echo ' <option value="">' . _x('Select Month', 'archives widget', 'uplifted') . '</option>';
echo $items;
echo ' </select>';
echo '</form>';
} else {
示例12: wp_get_archives
function wp_get_archives($args = '')
{
global $wp_locale, $wpdb;
if (is_array($args)) {
$r =& $args;
} else {
parse_str($args, $r);
}
$defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false);
$r = array_merge($defaults, $r);
extract($r);
if ('' == $type) {
$type = 'monthly';
}
if ('' != $limit) {
$limit = (int) $limit;
$limit = ' LIMIT ' . $limit;
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–';
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) {
$archive_day_date_format = get_option('date_format');
$archive_week_start_date_format = get_option('date_format');
$archive_week_end_date_format = get_option('date_format');
}
$add_hours = intval(get_option('gmt_offset'));
$add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
if ('monthly' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
if ($arcresults) {
$afterafter = $after;
foreach ($arcresults as $arcresult) {
$url = get_month_link($arcresult->year, $arcresult->month);
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('yearly' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type ='post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
if ($arcresults) {
$afterafter = $after;
foreach ($arcresults as $arcresult) {
$url = get_year_link($arcresult->year);
$text = sprintf('%d', $arcresult->year);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('daily' == $type) {
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
if ($arcresults) {
$afterafter = $after;
foreach ($arcresults as $arcresult) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date);
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('weekly' == $type) {
$start_of_week = get_option('start_of_week');
$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, {$start_of_week}) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY WEEK(post_date, {$start_of_week}), YEAR(post_date) ORDER BY post_date DESC" . $limit);
$arc_w_last = '';
$afterafter = $after;
if ($arcresults) {
foreach ($arcresults as $arcresult) {
if ($arcresult->week != $arc_w_last) {
$arc_year = $arcresult->yr;
$arc_w_last = $arcresult->week;
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
$url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', get_option('home'), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ($show_post_count) {
$after = ' (' . $arcresult->posts . ')' . $afterafter;
}
echo get_archives_link($url, $text, $format, $before, $after);
}
}
}
} elseif ('postbypost' == $type || 'alpha' == $type) {
'alpha' == $type ? $orderby = "post_title ASC " : ($orderby = "post_date DESC ");
$arcresults = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' ORDER BY {$orderby} {$limit}");
if ($arcresults) {
//.........这里部分代码省略.........
示例13: get_custom_post_type_archives
/**
* function that extend the wp_get_archives
* @see wp-includes/general-template.php
*
* @since 1.0.0
*/
public function get_custom_post_type_archives($args = '')
{
global $wpdb, $wp_locale;
$defaults = array('posttype' => 'post', 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC');
$r = wp_parse_args($args, $defaults);
if ('' == $r['posttype']) {
$r['posttype'] = 'post';
}
$posttype = $r['posttype'];
if ('' == $r['type']) {
$r['type'] = 'monthly';
}
if (!empty($r['limit'])) {
$r['limit'] = absint($r['limit']);
$r['limit'] = ' LIMIT ' . $r['limit'];
}
$order = strtoupper($r['order']);
if ('ASC' !== $order) {
$order = 'DESC';
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–';
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if (!$archive_date_format_over_ride) {
$archive_day_date_format = get_option('date_format');
$archive_week_start_date_format = get_option('date_format');
$archive_week_end_date_format = get_option('date_format');
}
/**
* Filter the SQL WHERE clause for retrieving archives.
*
* @since 2.2.0
*
* @param string $sql_where Portion of SQL query containing the WHERE clause.
* @param array $r An array of default arguments.
*/
$where = apply_filters('getarchives_where', "WHERE post_type = '{$posttype}' AND post_status = 'publish'", $r);
/**
* Filter the SQL JOIN clause for retrieving archives.
*
* @since 2.2.0
*
* @param string $sql_join Portion of SQL query containing JOIN clause.
* @param array $r An array of default arguments.
*/
$join = apply_filters('getarchives_join', '', $r);
$output = '';
$last_changed = wp_cache_get('last_changed', 'posts');
if (!$last_changed) {
$last_changed = microtime();
wp_cache_set('last_changed', $last_changed, 'posts');
}
$limit = $r['limit'];
if ('monthly' == $r['type']) {
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date {$order} {$limit}";
$key = md5($query);
$key = "get_custom_post_type_archives:{$key}:{$last_changed}";
if (!($results = wp_cache_get($key, 'posts'))) {
$results = $wpdb->get_results($query);
wp_cache_set($key, $results, 'posts');
}
if ($results) {
$after = $r['after'];
foreach ((array) $results as $result) {
$url = $this->get_custom_post_type_month_link($posttype, $result->year, $result->month);
/* translators: 1: month name, 2: 4-digit year */
$text = sprintf(__('%1$s %2$d', 'custom-post-type-widgets'), $wp_locale->get_month($result->month), $result->year);
if ($r['show_post_count']) {
$r['after'] = ' (' . $result->posts . ')' . $after;
}
$output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
}
}
}
if ($r['echo']) {
echo $output;
} else {
return $output;
}
}
示例14: get_wpu_latest_blogposts
function get_wpu_latest_blogposts($args = '')
{
global $wpuAbs, $wpdb;
$defaults = array('limit' => '20', 'before' => '<li>', 'after' => '</li>');
extract(_wpu_process_args($args, $defaults));
if ('' != $limit) {
$limit = (int) $limit;
$limit_sql = ' LIMIT ' . $limit;
}
$orderby_sql = "post_date DESC ";
$posts = $wpdb->get_results("SELECT ID, post_author, post_title FROM {$wpdb->posts} \n\t\tWHERE post_type = 'post' \n\t\tAND post_author <> 1\n\t\tAND post_status = 'publish' \n\t\tORDER BY {$orderby_sql} \n\t\t{$limit_sql}");
if ($posts) {
$htmlOut = '';
foreach ($posts as $post) {
$lastPostTitle = wpu_censor(strip_tags($post->post_title));
$blogTitle = wpu_censor(strip_tags(get_usermeta($post->post_author, 'blog_title')));
$blogTitle = $blogTitle == '' ? $wpuAbs->lang('default_blogname') : $blogTitle;
$lastPostURL = get_permalink($post->ID);
if (function_exists('get_author_posts_url')) {
//WP >= 2.1 branch
$blogPath = get_author_posts_url($post->post_author);
} else {
//deprecated branch
$blogPath = get_author_link(false, $author->post_author);
}
$postLink = get_archives_link($lastPostURL, $lastPostTitle, '', $before, '');
$blogLink = get_archives_link($blogPath, $blogTitle, '', '', $after);
$htmlOut .= sprintf(__('%s, in %s'), trim($postLink), $blogLink);
}
return $htmlOut;
}
}
示例15: wp_get_archives
function wp_get_archives($args = '') {
global $wpdb, $wp_locale;
$defaults = array(
'type' => 'monthly', 'limit' => '',
'format' => 'html', 'before' => '',
'after' => '', 'show_post_count' => false
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
if ( '' == $type )
$type = 'monthly';
if ( '' != $limit ) {
$limit = absint($limit);
$limit = ' LIMIT '.$limit;
}
// this is what will separate dates on weekly archive links
$archive_week_separator = '–';
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
if ( !$archive_date_format_over_ride ) {
$archive_day_date_format = get_option('date_format');
$archive_week_start_date_format = get_option('date_format');
$archive_week_end_date_format = get_option('date_format');
}
//filters
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
$join = apply_filters('getarchives_join', "", $r);
if ( 'monthly' == $type ) {
$query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
$key = md5($query);
$cache = wp_cache_get( 'wp_get_archives' , 'general');
if ( !isset( $cache[ $key ] ) ) {
$arcresults = $wpdb->get_results($query);
$cache[ $key ] = $arcresults;
wp_cache_add( 'wp_get_archives', $cache, 'general' );
} else {
$arcresults = $cache[ $key ];
}
if ( $arcresults ) {
$afterafter = $after;
foreach ( $arcresults as $arcresult ) {
$url = get_month_link($arcresult->year, $arcresult->month);
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count )
$after = ' ('.$arcresult->posts.')' . $afterafter;
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ('yearly' == $type) {
$query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
$key = md5($query);
$cache = wp_cache_get( 'wp_get_archives' , 'general');
if ( !isset( $cache[ $key ] ) ) {
$arcresults = $wpdb->get_results($query);
$cache[ $key ] = $arcresults;
wp_cache_add( 'wp_get_archives', $cache, 'general' );
} else {
$arcresults = $cache[ $key ];
}
if ($arcresults) {
$afterafter = $after;
foreach ($arcresults as $arcresult) {
$url = get_year_link($arcresult->year);
$text = sprintf('%d', $arcresult->year);
if ($show_post_count)
$after = ' ('.$arcresult->posts.')' . $afterafter;
echo get_archives_link($url, $text, $format, $before, $after);
}
}
} elseif ( 'daily' == $type ) {
$query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
$key = md5($query);
$cache = wp_cache_get( 'wp_get_archives' , 'general');
if ( !isset( $cache[ $key ] ) ) {
$arcresults = $wpdb->get_results($query);
$cache[ $key ] = $arcresults;
wp_cache_add( 'wp_get_archives', $cache, 'general' );
} else {
$arcresults = $cache[ $key ];
}
if ( $arcresults ) {
$afterafter = $after;
foreach ( $arcresults as $arcresult ) {
$url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
//.........这里部分代码省略.........