• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_month_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_month_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_month_link函数的具体用法?PHP get_month_link怎么用?PHP get_month_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_month_link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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>';
 }
开发者ID:ashanrupasinghe,项目名称:amc-car-from-server-2015-1-14,代码行数:29,代码来源:post_widget.php


示例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'] = '&nbsp;(' . $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;
 }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:60,代码来源:wp_archives_monthly.php


示例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;
 }
开发者ID:bidhanbaral,项目名称:fotodep_store,代码行数:35,代码来源:archive.php


示例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;
}
开发者ID:kevalbaxi,项目名称:dosomething-blog,代码行数:59,代码来源:thumbnail.php


示例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, ' &raquo; ') . '</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;
     }
 }
开发者ID:nego-solutions,项目名称:ns-breadcrumb,代码行数:61,代码来源:class-fw-extension-ns-breadcrumb.php


示例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;
    }
开发者ID:jazbek,项目名称:accordion-archive-widget,代码行数:56,代码来源:accordion-archive-widget.php


示例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>';
}
开发者ID:stefbowerman,项目名称:elder-journal-vs,代码行数:14,代码来源:functions.php


示例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());
 }
开发者ID:statnews,项目名称:ad-layers,代码行数:12,代码来源:test-page-types.php


示例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;
    }
开发者ID:oguzhank77,项目名称:better-archives-widget,代码行数:52,代码来源:widget-archives.php


示例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;
    }
开发者ID:ashenkar,项目名称:sanga,代码行数:49,代码来源:archive.php


示例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>';
    }
}
开发者ID:synergia,项目名称:mknm-synergia-theme,代码行数:15,代码来源:archive.php


示例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;
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:23,代码来源:posts.php


示例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'))));
    }
开发者ID:boonebgorges,项目名称:wp,代码行数:16,代码来源:getArchives.php


示例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();
}
开发者ID:jbogota,项目名称:blog-king,代码行数:16,代码来源:king_clouds.php


示例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;
}
开发者ID:rhondamoananui,项目名称:rehub,代码行数:47,代码来源:template-timeline.php


示例16: teaberry_entry_meta

/**
 * get meta information for current post
 */
function teaberry_entry_meta()
{
    /* used between list items */
    $cats = get_the_category_list(', ');
    $tags = get_the_tag_list('', ', ');
    $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_month_link(get_post_time('Y'), get_post_time('m'))), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()));
    $name = 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', 'teaberry'), get_the_author())), get_the_author());
    /* make meta text */
    if ($tags) {
        $text = __('Added in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    } elseif ($cats) {
        $text = __('Added in %1$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    } else {
        $text = __('Added on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry');
    }
    printf($text, $cats, $tags, $date, $name);
}
开发者ID:honeymustard,项目名称:teaberry,代码行数:20,代码来源:meta.php


示例17: otat_month_archives

function otat_month_archives()
{
    global $wpdb;
    $where = "WHERE post_type = 'post' AND post_status = 'publish'";
    $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM {$wpdb->posts} {$where} GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY YEAR DESC, MONTH ASC";
    $_archive = $wpdb->get_results($query);
    $last_year = (int) $_archive[0]->year;
    $first_year = (int) $_archive[count($_archive) - 1]->year;
    $archive = array();
    $max = 0;
    $year_total = array();
    foreach ($_archive as $data) {
        if (!isset($year_total[$data->year])) {
            $year_total[$data->year] = 0;
        }
        $archive[$data->year][$data->month] = $data->posts;
        $year_total[$data->year] += $data->posts;
        $max = max($max, $data->posts);
    }
    unset($_archive);
    for ($year = $last_year; $year >= $first_year; $year--) {
        echo '<div class="archive_year">';
        echo '<span class="archive_year_label">' . $year;
        if (isset($year_total[$year])) {
            echo '<span class="archive_year_count">' . $year_total[$year] . ' tweets</span>';
        }
        echo '</span>';
        echo '<ol>';
        for ($month = 1; $month <= 12; $month++) {
            $num = isset($archive[$year][$month]) ? $archive[$year][$month] : 0;
            $empty = $num ? 'not_empty' : 'empty';
            echo "<li class='{$empty}'>";
            $height = 100 - max(floor($num / $max * 100), 20);
            if ($num) {
                $url = get_month_link($year, $month);
                $m = str_pad($month, 2, "0", STR_PAD_LEFT);
                echo "<a href='{$url}' title='{$m}/{$year} : {$num} tweets'><span class='bar_wrap'><span class='bar' style='height:{$height}%'></span></span>";
                echo "<span class='label'>" . $m . "</span>";
                echo "</a>";
            }
            echo '</li>';
        }
        echo '</ol>';
        echo "</div>";
    }
}
开发者ID:kw217,项目名称:ozh-tweet-archive-theme,代码行数:46,代码来源:functions.php


示例18: 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;
    }
}
开发者ID:jainankit,项目名称:suggstme,代码行数:45,代码来源:theme-shortcodes.php


示例19: _exitingDir

 function _exitingDir($directory = null, $file = null)
 {
     $y = $this->_year;
     if ($mos =& $this->_months) {
         sort($mos);
         $list = '';
         $linearlist = array();
         foreach ($mos as $mth) {
             $lnk = get_month_link($y, $mth);
             $the_month = theme_date_format(mktime(0, 0, 0, $mth, 1, 0), '%B');
             $list = "<li class=\"archive-month archive-m{$mth}\"><a href=\"{$lnk}\">" . $the_month . ' </a></li>' . $list;
             $linearlist["{$the_month} 20{$this->_year}"] = $lnk;
         }
         $list = '<ul>' . $list . '</ul>';
     }
     $mos = array();
     // we close year's li
     $this->_list[$y] = $linearlist;
     $this->_htmllist[$y] .= $list . '</li>';
 }
开发者ID:mroussel,项目名称:flatpress,代码行数:20,代码来源:plugin.archives.php


示例20: get_items_montly

 function get_items_montly($args, $last_changed, $join, $where, $order, $limit, $nested = true)
 {
     global $wpdb, $wp_locale;
     $output = array();
     $defaults = array('show_year' => true);
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     $where = $where;
     //will need to specify which year we're looking for
     $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 = "wp_get_archives:{$key}:{$last_changed}";
     if (!($results = wp_cache_get($key, 'posts'))) {
         $results = $wpdb->get_results($query);
         wp_cache_set($key, $results, 'posts');
     }
     if ($results) {
         foreach ((array) $results as $result) {
             $url = get_month_link($result->year, $result->month);
             /* translators: 1: month name, 2: 4-digit year */
             if ($show_year && !$nested) {
                 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
             } else {
                 $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
             }
             if ($nested) {
                 $output[$result->year][] = $this->get_archives_link($url, $text);
             } else {
                 $output[] = $this->get_archives_link($url, $text);
             }
         }
     }
     if ($nested) {
         $out2 = array();
         foreach ($output as $year => $months) {
             $out2[] = array('name' => $year, 'children' => $months);
         }
         return $out2;
     }
     return $output;
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:41,代码来源:timber-archives.php



注:本文中的get_month_link函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_moodle_cookie函数代码示例发布时间:2022-05-15
下一篇:
PHP get_monday_before函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap