本文整理汇总了PHP中get_month_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_month_link函数的具体用法?PHP get_month_link怎么用?PHP get_month_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_month_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _meta_data
private function _meta_data($view, $params)
{
$defaults = array('class' => '');
$params = wp_parse_args($params, $defaults);
$content = '';
// Date
$content .= '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" class="blog_date"><i class="icon-calendar"></i>' . get_the_date('F j, Y') . '</a>';
// Categories
$post_categories = wp_get_post_categories(get_the_ID());
$categories = array();
foreach ($post_categories as $c) {
$cat = get_category($c);
$categories[] = '<a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a>';
}
if (count($categories) > 0) {
$content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $categories) . '</div>';
}
// Author
$content .= '<span class="blog_author"><i class="icon-user"></i>' . get_the_author() . '</span>';
$post_tags = wp_get_post_tags(get_the_ID());
$tags = array();
foreach ($post_tags as $tag) {
$tags[] = '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
}
if (count($tags) > 0) {
$content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $tags) . '</div>';
}
return '<div class="' . $params['class'] . '">' . $content . '</div>';
}
示例2: _b_wp_archives_monthly_show
function _b_wp_archives_monthly_show($options, $wp_num = '')
{
$block_style = $options[0] ? $options[0] : 0;
$with_count = $options[1] == 0 ? false : true;
$tpl_file = empty($options[2]) ? 'wp_archives_monthly.html' : $options[2];
$sel_value = '';
if (current_wp()) {
if (!empty($_SERVER['PATH_INFO'])) {
permlink_to_param();
}
init_param('GET', 'm', 'string', '');
init_param('GET', 'year', 'integer', '');
init_param('GET', 'monthnum', 'integer', '');
init_param('GET', 'day', 'integer', '');
if (strlen(get_param('m')) == 6) {
$sel_value = get_param('m');
} else {
if (test_param('year') && test_param('monthnum') && !test_param('day')) {
$sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
}
}
}
$block['wp_num'] = $wp_num;
$block['divid'] = 'wpArchive' . $wp_num;
$block['siteurl'] = wp_siteurl();
$block['style'] = block_style_get(false);
$block['block_style'] = $block_style;
$block['with_count'] = $with_count;
$now = current_time('mysql');
$postHandler =& wp_handler('Post');
$criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<'));
$criteria->add(new Criteria('post_status', 'publish'));
$criteria->setSort('post_date');
$criteria->setOrder('DESC');
$criteria->setGroupby('YEAR(post_date), MONTH(post_date)');
$postObjects =& $postHandler->getObjects($criteria, false, 'DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts');
$block['records'] = array();
if ($postObjects) {
foreach ($postObjects as $postObject) {
$this_year = $postObject->getExtraVar('year');
$this_month = $postObject->getExtraVar('month');
$_record['url'] = get_month_link($this_year, $this_month);
$_record['text'] = format_month($this_year, $GLOBALS['month'][zeroise($this_month, 2)]);
if ($with_count) {
$_record['count'] = ' (' . $postObject->getExtraVar('posts') . ')';
} else {
$_record['count'] = '';
}
$_record['select'] = $sel_value == $this_year . zeroise($this_month, 2) ? 'selected="selected"' : '';
$block['records'][] = $_record;
}
}
$_wpTpl =& new WordPresTpl('theme');
$_wpTpl->assign('block', $block);
if (!$_wpTpl->tpl_exists($tpl_file)) {
$tpl_file = 'wp_archives_monthly.html';
}
$block['content'] = $_wpTpl->fetch($tpl_file);
return $block;
}
示例3: widget
function widget($args, $instance)
{
extract($args);
$c = $instance['count'] ? '1' : '0';
$archive_type = $instance['archive_type'] ? '1' : '0';
$title = apply_filters('widget_title', __('Archives', 'unspoken'));
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
if ($archive_type == 0) {
$categories = get_categories();
$output = '<ul>';
foreach ($categories as $category) {
$output .= sprintf('<li><a href="%1$s" title="%2$s">%3$s</a><span>%4$s</span></li>', get_category_link($category->term_id), sprintf(__('View all posts in %s', 'unspoken'), $category->name), $category->name, $c ? $category->count : '');
}
$output .= '</ul>';
} else {
global $wpdb, $wp_locale;
// set limit for list
$archive_limit = 0;
// query
$q = "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', COUNT(ID) as post_count " . "FROM {$wpdb->posts} " . "WHERE post_type = 'post' AND post_status = 'publish' " . "GROUP BY month, year " . "ORDER BY post_date DESC" . ($archive_limit == 0 ? '' : ' LIMIT ' . $archive_limit);
// make query for result
$months = $wpdb->get_results($q);
$output = '<ul>';
// looping through result
foreach ($months as $month) {
$output .= sprintf('<li><a href="%1$s">%2$s<span>%3$s</span></a></li>', get_month_link($month->year, $month->month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month->month), $month->year), $c ? $month->post_count : '');
}
$output .= '</ul>';
}
echo $output;
echo $after_widget;
}
示例4: blog_thumbnail_style
function blog_thumbnail_style($atts, $current)
{
global $post, $mk_options;
extract($atts);
$image_height = $grid_image_height;
if ($thumbnail_align == 'left') {
$align_class = ' content-align-right';
} else {
$align_class = ' content-align-left';
}
if ($layout == 'full') {
$image_width = $grid_width - 40;
} else {
$image_width = $content_width / 100 * $grid_width - 40;
}
$output = $has_image = '';
$post_type = get_post_meta($post->ID, '_single_post_type', true);
/*
* Image Width : 600px
* Image Height : 460px
*/
$image_src_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
$image_output_src = bfi_thumb($image_src_array[0], array('width' => '600', 'height' => '460'));
if ($post_type == '') {
$post_type = 'image';
}
$output .= '<article id="' . get_the_ID() . '" class="mk-blog-thumbnail-item thumbnail-' . $item_id . ' mk-isotop-item ' . $post_type . '-post-type' . $align_class . '">' . "\n";
if (has_post_thumbnail()) {
$output .= '<div class="featured-image" ><a href="' . get_permalink() . '" title="' . get_the_title() . '">';
$output .= ' <img alt="' . get_the_title() . '" title="' . get_the_title() . '" src="' . $image_output_src . '" itemprop="image" />';
$output .= ' <div class="image-hover-overlay"></div>';
$output .= ' <div class="post-type-badge" href="' . get_permalink() . '"><i class="mk-li-' . $post_type . '"></i></div>';
$output .= '</a></div>';
}
$output .= '<div class="mk-thumbnail-content-container">';
$output .= ' <div class="mk-blog-meta">';
$output .= ' <div class="mk-blog-author">';
ob_start();
the_author_posts_link();
$output .= ob_get_contents() . '</div>';
ob_get_clean();
$output .= ' <span class="mk-categories"> / ' . __('', 'mk_framework') . ' ' . get_the_category_list(', ') . ' </span> /
<time datetime="' . get_the_date() . '">
<a href="' . get_month_link(get_the_time("Y"), get_the_time("m")) . '">' . get_the_date() . '</a>
</time>';
$output .= ' <h3 class="the-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
if ($excerpt_length != 0) {
ob_start();
the_excerpt_max_charlength($excerpt_length);
$output .= '<div class="the-excerpt"><p>' . ob_get_clean() . '</p></div>';
}
$output .= ' <div class="mk-teader-button">' . do_shortcode('[mk_button dimension="outline" corner_style="pointed" outline_skin="custom" outline_active_color="#000000" outline_hover_color="#fff" margin_bottom="0" size="medium" align="left" url="' . get_permalink() . '"]' . __('READ MORE', 'mk_framework') . '[/mk_button]') . '
</div>';
$output .= ' </div>';
$output .= ' </div>';
$output .= '<div class="clearboth"></div>';
$output .= '</article>' . "\n\n\n";
return $output;
}
示例5: output_html
/**
* This checks on which page we're and display the correct breancrumb navigation
* @return string | void
*/
public function output_html()
{
global $post, $cat, $wp_query;
$output = '';
$arc_year = get_the_time('Y');
$arc_month = get_the_time('F');
$arc_day = get_the_time('d');
$arc_day_full = get_the_time('l');
$url_year = get_year_link($arc_year);
$url_month = get_month_link($arc_year, $arc_month);
$templates = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-templates', array()));
$types = array_keys(fw_get_db_ext_settings_option('ns-breadcrumb', 'hide-bdb-types', array()));
if (in_array(get_post_type(), $types)) {
return;
}
if (!is_front_page()) {
//breadcrumb for single post
if (is_single() && !in_array('single', $templates)) {
$output = $this->is_single_post();
} elseif (is_category() && !in_array('category', $templates)) {
$output = '<li>' . $this->set_opt('category') . get_category_parents($cat, true, ' » ') . '</li>';
} elseif (is_tax() && !in_array('category', $templates)) {
$term = $wp_query->queried_object;
$output = '<li>' . $this->set_opt('category') . $term->name . '</li>';
} elseif (is_tag() && !in_array('tag', $templates)) {
$output = '<li>' . $this->set_opt('tags') . single_tag_title('', false) . '</li>';
} elseif (is_day() && !in_array('archive', $templates)) {
$output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li>';
$output .= '<li><a href="' . $url_month . '">' . $arc_month . '</a></li><li>' . $arc_day . ' (' . $arc_day_full . ')</li>';
} elseif (is_month() && !in_array('archive', $templates)) {
$output = '<li><a href="' . $url_year . '">' . $arc_year . '</a></li><li>' . $arc_month . '</li>';
} elseif (is_year() && !in_array('archive', $templates)) {
$output = '<li>' . $arc_year . '</li>';
} elseif (is_search() && !in_array('search', $templates)) {
$output = '<li>' . $this->set_opt('search') . get_search_query() . '</li>';
} elseif (is_page() && !$post->post_parent && !in_array('page', $templates)) {
$output = '<li>' . get_the_title() . '</li>';
} elseif (is_page() && $post->post_parent && !in_array('page', $templates)) {
$output = $this->is_page_n_has_parent();
} elseif (is_author() && !in_array('author', $templates)) {
global $author;
$user_info = get_userdata($author);
$output = '<li>' . $this->set_opt('author') . $user_info->display_name . '</li>';
} elseif (is_404() && !in_array('404', $templates)) {
$output = '<li>' . $this->set_opt('error') . '</li>';
} else {
//All other cases no Breadcrumb trail.
}
}
if (!empty($output)) {
$return = '<ul class="breadcrumb">';
$return .= $this->set_opt('el_prefix');
$return .= $output;
$return .= '</ul>';
echo $return;
}
}
示例6: widget
function widget($args, $instance)
{
extract($args);
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters('widget_title', empty($instance['title']) ? __('Accordion Archives') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<ul>
<?php
/**
* Filter the arguments for the Archives widget.
*
* @since 2.8.0
*
* @see wp_get_archives()
*
* @param array $args An array of Archives option arguments.
*/
$archives = strip_tags(wp_get_archives(apply_filters('widget_accordion_archives_args', array('type' => 'monthly', 'format' => 'custom', 'echo' => 0, 'after' => ','))));
$archives = explode(',', $archives);
$months = array();
$years = array();
// Grab our years first
foreach ($archives as $archive) {
$archive = explode(' ', $archive);
if (isset($archive[1])) {
array_push($years, $archive[1]);
}
}
$years = array_values(array_unique($years));
$i = 0;
foreach ($years as $year) {
?>
<li class="archive-accordion-year"><a><?php
echo $year;
?>
</a><ul><?php
foreach ($archives as $archive) {
$archive = explode(' ', $archive);
if (!empty($archive[1]) && $archive[1] == $year) {
echo '<li class="archive-accordion-month"><a href="' . get_month_link($year, date("m", strtotime($archive[0] . '-' . $year))) . '">' . trim($archive[0]) . '</a></li>';
}
}
?>
</ul><?php
?>
</li><?php
}
?>
</ul>
<?php
echo $after_widget;
}
示例7: elder_linkable_date
/**
* Prints the date for a post with the month + date linkable to the moth archive and the year linked to the yearly archive
* Date looks like - "September 21, 2014"
*/
function elder_linkable_date()
{
global $year, $currentmonth;
printf('<a href="%1$s" title="View posts from %2$s %3$s">', get_month_link($year, $currentmonth), get_the_date('F'), get_the_date('Y'));
echo get_the_date('F') . ' ' . get_the_date('j');
echo '</a>, ';
printf('<a href="%1$s" title="View posts from %2$s">', get_year_link($year), get_the_date('Y'));
echo get_the_date('Y');
echo '</a>';
}
示例8: test_page_type_date
public function test_page_type_date()
{
$this->go_to(get_year_link('2015'));
$this->assertTrue(is_year());
$this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
$this->go_to(get_month_link('2015', '03'));
$this->assertTrue(is_month());
$this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
$this->go_to(get_day_link('2015', '03', '14'));
$this->assertTrue(is_day());
$this->assertSame('date', Ad_Layers::instance()->get_current_page_type());
}
示例9: widget
function widget($args, $instance)
{
extract($args);
echo $before_widget;
$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives', 'better-archives-widget') : $instance['title'], $instance, $this->id_base);
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
// years - months
global $wpdb;
$prevYear = '';
$currentYear = '';
if ($months = $wpdb->get_results("SELECT DISTINCT DATE_FORMAT(post_date, '%b') AS month , MONTH(post_date) as numMonth, YEAR( post_date ) AS year, COUNT( id ) as post_count FROM {$wpdb->posts} WHERE post_status = 'publish' and post_date <= now() and post_type = 'post' GROUP BY month , year ORDER BY post_date DESC")) {
echo '<ul>';
foreach ($months as $month) {
$currentYear = $month->year;
if ($currentYear !== $prevYear && '' !== $prevYear) {
echo '</ul></li>';
}
if ($currentYear !== $prevYear) {
?>
<li class="baw-year">
<a href="<?php
echo esc_url(get_year_link($month->year));
?>
"><?php
echo esc_html($month->year);
?>
</a>
<ul class="baw-months">
<?php
}
?>
<li class="baw-month">
<a href="<?php
echo esc_url(get_month_link($month->year, $month->numMonth));
?>
"><?php
echo esc_html($month->month . ' ' . $month->year);
?>
</a>
</li>
<?php
$prevYear = $month->year;
}
}
?>
</ul></li>
<?php
echo '</ul>';
echo $after_widget;
}
示例10: generate_data
protected function generate_data()
{
global $wpdb;
$requested = $this->requested;
if ('monthly' == $requested) {
$latest_post_query = '
SELECT
YEAR(post_date) as year,
MONTH(post_date) as month,
MAX(post_modified) as post_modified,
MAX(post_modified_gmt) as post_modified_gmt,
MAX(comment_count) as comment_count
FROM ' . $wpdb->posts . "\n\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\tAND post_password = ''\n\t\t\t\t\tAND post_type = 'post'" . '
GROUP BY year, month
ORDER BY post_modified DESC';
} else {
$latest_post_query = '
SELECT
YEAR(post_date) as year,
MAX(post_modified) as post_modified,
MAX(post_modified_gmt) as post_modified_gmt,
MAX(comment_count) as comment_count
FROM ' . $wpdb->posts . "\n\t\t\t\tWHERE post_status = 'publish'\n\t\t\t\t\tAND post_password = ''\n\t\t\t\t\tAND post_type <> 'page'" . '
GROUP BY year
ORDER BY post_modified DESC';
}
$latest_posts = $this->get_results($latest_post_query);
if (!isset($latest_posts) || 0 == sizeof($latest_posts)) {
return false;
}
$data = array();
for ($i = 0; $i < sizeof($latest_posts); $i++) {
$post = $latest_posts[$i];
$data = $this->init_data($data);
if ('monthly' == $requested) {
$data['location'] = get_month_link($post->year, $post->month);
} else {
if ('yearly' == $requested) {
$data['location'] = get_year_link($post->year);
}
}
$data['lastmod'] = $this->get_lastmod($post);
$data['freq'] = $this->cal_frequency($post);
$data['priority'] = $this->cal_priority($post, $data['freq']);
$this->data[] = $data;
}
unset($latest_posts);
return true;
}
示例11: show_nested_archive
function show_nested_archive()
{
foreach (get_posts_by_years() as $year) {
echo '<div class="gl-cell gl-md-4 gl-lg-3 left">';
echo '<dl class="dropy archive-year"><dt class="dropy__title"><h2>' . $year . '<i class="icon-down-open-mini"></i></h2></dt>';
echo '<dd class="dropy__content"><ul>';
foreach (get_posts_by_months($year) as $month) {
echo '<li><a href="' . get_month_link($year, $month) . '">';
echo date_i18n('F', mktime(0, 0, 0, $month)) . '</a>';
echo '</li>';
}
echo '</ul></dd><input type="hidden" name="first"></dl>';
echo '</div>';
}
}
示例12: get_rocket_post_dates_urls
/**
* Get all dates archives urls associated to a specific post
*
* @since 1.0
*
* @param int $post_ID The post ID
* @return array $urls List of dates URLs
*/
function get_rocket_post_dates_urls($post_ID)
{
// Get the day and month of the post
$date = explode('-', get_the_time('Y-m-d', $post_ID));
$urls = array(get_year_link($date[0]) . 'index.html', get_year_link($date[0]) . $GLOBALS['wp_rewrite']->pagination_base, get_month_link($date[0], $date[1]) . 'index.html', get_month_link($date[0], $date[1]) . $GLOBALS['wp_rewrite']->pagination_base, get_day_link($date[0], $date[1], $date[2]));
/**
* Filter the list of dates URLs
*
* @since 1.1.0
*
* @param array $urls List of dates URLs
*/
$urls = apply_filters('rocket_post_dates_urls', $urls);
return $urls;
}
示例13: test_wp_get_archives_order
function test_wp_get_archives_order()
{
$this->factory->post->create(array('post_type' => 'post', 'post_author' => '1', 'post_date' => '2012-10-23 19:34:42'));
$date_full = date('F Y');
$oct_url = get_month_link(2012, 10);
$expected['order_asc'] = <<<EOF
<li><a href='{$oct_url}'>October 2012</a></li>
\t<li><a href='{$this->month_url}'>{$date_full}</a></li>
EOF;
$this->assertEquals($expected['order_asc'], trim(wp_get_archives(array('echo' => false, 'order' => 'ASC'))));
$expected['order_desc'] = <<<EOF
<li><a href='{$this->month_url}'>{$date_full}</a></li>
\t<li><a href='{$oct_url}'>October 2012</a></li>
EOF;
$this->assertEquals($expected['order_desc'], trim(wp_get_archives(array('echo' => false, 'order' => 'DESC'))));
}
示例14: archives_cloud
function archives_cloud($smallest = 50, $largest = 200, $unit = "%", $cold = "", $hot = "", $before = '', $after = '', $exclude = '')
{
global $month, $wpdb;
$now = current_time('mysql');
$results = $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"' . ' GROUP BY YEAR(post_date), MONTH(post_date)' . ' ORDER BY post_date DESC');
$content = array();
foreach ($results as $key => $val) {
# normalize the values to fit into KingCloud Class content var
$content[$key]['url'] = get_month_link($val->year, $val->month);
$content[$key]['text'] = sprintf('%s %d', $month[zeroise($val->month, 2)], $val->year);
$content[$key]['title'] = $val->posts . ' Artikel';
$content[$key]['count'] = $val->posts;
}
$cloud = new KingCloud($content, $smallest, $largest, $unit, $cold, $hot, $before, $after);
$cloud->output();
}
示例15: 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;
}