本文整理汇总了PHP中wp_get_archives函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_archives函数的具体用法?PHP wp_get_archives怎么用?PHP wp_get_archives使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_archives函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/**
* Widget
*
* @return void
* @since 1.0
*/
function widget($args, $instance)
{
if (false == ($cache = get_transient('edd_widgets_archives'))) {
// get the title and apply filters
$title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : '');
// get show count boolean
$show_count = isset($instance['show_count']) && $instance['show_count'] === 1 ? 1 : 0;
// start collecting the output
$out = "";
// check if there is a title
if ($title) {
// add the title to the ouput
$out .= $args['before_title'] . $title . $args['after_title'];
}
$out .= "<ul>\n";
// add download post type to archives
add_filter('getarchives_where', array(&$this, 'getarchives_where_filter'), 10, 2);
add_filter('month_link', array($this, 'month_link'), 10, 3);
// output the archives
$out .= wp_get_archives(array('echo' => 0, 'show_post_count' => $show_count));
// remove filter
remove_filter('getarchives_where', array(&$this, 'getarchives_where_filter'), 10, 2);
remove_filter('month_link', array($this, 'month_link'), 10, 3);
// finish the list
$out .= "</ul>\n";
// set the widget's containers
$cache = $args['before_widget'] . $out . $args['after_widget'];
// store the result on a temporal transient
set_transient('edd_widgets_archives', $cache);
}
echo $cache;
}
示例2: Grafik_Functions_Shortcode_TypeArchives
function Grafik_Functions_Shortcode_TypeArchives($atts, $content = '')
{
global $wp_query;
global $GRAFIK_MODE;
$callback_output = '';
$a = shortcode_atts(array('type' => 'post', 'format' => 'links', 'class' => '', 'id' => ''), $atts, 'TypeArchives');
// Construct the query...
$callback_query = new WP_Query(array('post_type' => $a['type'], 'posts_per_page' => -1));
// Loop the query...
preg_match_all("/<li><a[\\s]*href=[\"']([^\"']*)[\"'][^>]*>([^<]*)<\\/a>[^\\(]*\\(([^\\)]*)\\)<\\/li>/i", wp_get_archives(array('post_type' => $a['type'], 'type' => 'monthly', 'show_post_count' => true, 'echo' => 0)), $callback_archives);
// Restructure the array...
$callback_restructured = array();
foreach ($callback_archives as $key => $val) {
foreach ($val as $val_key => $val_val) {
$callback_restructured[$val_key][$key] = $val_val;
}
}
$callback_archives = $callback_restructured;
// Loop the results...
foreach ($callback_archives as $key => $val) {
$callback_output .= '<li class="ge-typearchives-item">' . '<a href="' . esc_url($val[1]) . '" class="ge-typearchives-link">' . '<span class="ge-typearchives-name">' . $val[2] . '</span>' . '<span class="ge-typearchives-count">' . $val[3] . '</span>' . '</a>' . '</li>';
}
if (empty($callback_output)) {
return '';
}
return '<div class="ge-typearchives-container' . (empty($a['class']) ? null : ' ' . $a['class']) . '"' . (empty($a['id']) ? null : ' id="' . $a['id'] . '"') . '>' . '<div class="ge-typearchives-content">' . $content . '</div>' . '<ul class="ge-typearchives-list' . ($a['format'] == 'dropdown' ? 'dropdown' : '') . '">' . $callback_output . '</ul>' . '</div>';
}
示例3: widget
function widget($args, $instance)
{
$before_widget = $before_title = $after_title = $after_widget = '';
extract($args);
$c = !empty($instance['count']) ? '1' : '0';
$d = !empty($instance['dropdown']) ? '1' : '0';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives', 'zn_framework') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
if ($d) {
?>
<select name="archive-dropdown"
onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php
echo esc_attr(__('Select Month', 'zn_framework'));
?>
</option>
<?php
wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c)));
?>
</select>
<?php
} else {
?>
<ul class="menu">
<?php
wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c)));
?>
</ul>
<?php
}
echo $after_widget;
}
示例4: ts_sitemap_func
function ts_sitemap_func($atts)
{
extract(shortcode_atts(array('sitemap' => ''), $atts));
$html = '';
ob_start();
?>
<ul class="sitemap">
<?php
switch ($sitemap) {
case 'pages':
wp_list_pages("title_li=");
break;
case 'posts':
$archive_query = new WP_Query('showposts=1000&cat=-8');
while ($archive_query->have_posts()) {
$archive_query->the_post();
}
break;
case 'archives':
wp_get_archives('type=monthly&show_post_count=true');
break;
default:
wp_list_pages("title_li=");
break;
}
?>
</ul>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
示例5: getWordpressData
static function getWordpressData() {
/**
* Get all global page data
*/
$blogDataParams = array(
'url', 'wpurl', 'description', 'rdf_url' , 'rss_url', 'rss2_url'
, 'atom_url', 'comments_atom_url', 'comments_rss2_url', 'pingback_url'
, 'stylesheet_url', 'stylesheet_directory', 'template_directory'
, 'template_url', 'admin_email', 'charset', 'html_type', 'version'
, 'language', 'text_direction', 'name'
);
$blogData = array();
foreach($blogDataParams as $blogDataParam) {
$blogData[self::toCamelCase($blogDataParam)] = get_bloginfo($blogDataParam);
}
$blogData = array_merge($blogData, array(
'title' => wp_title(' | ', false, 'right') . get_bloginfo('name'),
'archiveLinksHTML' => wp_get_archives('type=monthly&limit=5&format=link&echo=0'),
'bodyClasses' => self::getEchoFunctionContents('body_class'),
'posts' => array()
));
/**
* Get posts data
*/
while (have_posts()) {
the_post();
$postId = get_the_ID();
// Get category data
$categories = get_the_category();
$categoryNames = array();
foreach($categories as $category) {
array_push($categoryNames, $category->cat_name);
}
// Add all relevant post data to the posts array
array_push(
$blogData['posts'],
array_merge(
get_object_vars(get_post($postId)),
array(
'classes' => get_post_class(),
'comments' => get_comments(array('post_id' => $postId)),
'custom' => get_post_custom(),
'permalink' => get_permalink(),
'categories' => $categories,
'categoryNames' => $categoryNames,
'categoriesStr' => implode(',', $categoryNames)
)
)
);
}
return $blogData;
}
示例6: genesis_page_archive_content
/**
* This function outputs sitemap-esque columns displaying all pages,
* categories, authors, monthly archives, and recent posts.
*
* @since 1.6
*/
function genesis_page_archive_content()
{
// Pause Exclude Pages plugin functionality.
pause_exclude_pages();
?>
<h4><?php
_e('Pages:', 'genesis');
?>
</h4>
<ul>
<?php
wp_list_pages('title_li=');
?>
</ul>
<h4><?php
_e('Categories:', 'genesis');
?>
</h4>
<ul>
<?php
wp_list_categories('sort_column=name&title_li=');
?>
</ul>
<h4><?php
_e('Authors:', 'genesis');
?>
</h4>
<ul>
<?php
wp_list_authors('exclude_admin=0&optioncount=1');
?>
</ul>
<h4><?php
_e('Monthly:', 'genesis');
?>
</h4>
<ul>
<?php
wp_get_archives('type=monthly');
?>
</ul>
<h4><?php
_e('Recent Posts:', 'genesis');
?>
</h4>
<ul>
<?php
wp_get_archives('type=postbypost&limit=100');
?>
</ul>
<?php
// Resume Exclude Pages plugin functionality.
resume_exclude_pages();
}
示例7: archives_shortcode
public static function archives_shortcode($atts)
{
$defaults = array('type' => 'monthly', 'limit' => '', 'show_post_count' => 0, 'order' => 'DESC');
extract(shortcode_atts($defaults, $atts));
$archives_args = array('type' => $type, 'limit' => $limit, 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => $show_post_count, 'echo' => 0, 'order' => $order);
return '<ul>' . "\n" . wp_get_archives($archives_args) . '</ul>' . "\n" . '<!-- Powered by Extra Shortcodes wordpress.org/plugins/extra-shortcodes/ -->';
}
示例8: getSidebar
function getSidebar()
{
$posts = $sidebar = '
<div class="container-aside quiet">
<h4 style="margin-bottom: .5em;" class="loud">Want another bite? Subscribe!</h4>
<p><a href="http://feeds.feedburner.com/kennethreitz" target="_none">RSS</a>, <a href="http://feedburner.google.com/fb/a/mailverify?uri=kennethreitz&loc=en_US" target="_none">Email</a>, <a href="http://friendfeed.com/kennethreitz" target="_none">FriendFeed</a>, <a href="http://twitter.com/kennethreitz" target="_none">Twitter</a>, <a href="http://www.facebook.com/pages/KennethReitzcom/144095770952?ref=ts" target="_none">Facebook</a>.<br/> If you see something that makes you shake with excitment or surge with rage, leave a comment and <a href="javascript:var%20e=document.createElement(\'script\');e.setAttribute(\'language\',\'javascript\');e.setAttribute(\'src\',\'http://bit.ly/bookmarklet/load.js\');document.body.appendChild(e);void(0);">send a link</a> to others!</p>
<hr/>
<h4 class="loud">About @KennethReitz</h4>
<p>
<strong>Kenneth Reitz, <em>n</em></strong>:
Open Mind. Open Source.<br/>
<strong>Location?</strong> Winchester, Virginia. <br/>
<strong>Field?</strong> Web Application Development <br/>
<strong>What??</strong> I make websites.<br/>
<strong>Language? </strong> Python. <em>Everything</em> else.<br/>
<strong>Tools?</strong> MacBook + iPhone + Moleskine = 42.<br/>
<strong>Anything Else?</strong> Life is wonderful.</p>
<hr/>
<h4>Latest Posts</h4>';
echo $sidebar;
echo wp_get_archives('format=custom&after=… &type=postbypost&limit=15&show_post_count=false');
echo '<hr/>';
echo '<p class="extra-quiet">';
echo fortune(3000);
echo '<p>';
echo '</div></div>';
}
示例9: wp_get_cat_archives
function wp_get_cat_archives($opts, $cat)
{
$args = wp_parse_args($opts, array('echo' => '1'));
// default echo is 1.
// 与えられた $opts を解析して配列に入れ、第2引数 と結合
$echo = $args['echo'] != '0';
// remember the original echo flag.
$args['echo'] = 0;
$args['cat'] = $cat;
$archives = wp_get_archives(build_query($args));
// アーカイブ取得 // 連想配列からページ用のクエリー文字列を作る
$archs = explode('</li>', $archives);
// 配列化した変数
$links = array();
foreach ($archs as $archive) {
$link = preg_replace("/href='([^']+)'/", "href='\$1?cat={$cat}'", $archive);
// 正規表現での置き換え
array_push($links, $link);
// 配列の末尾に値を追加
}
$result = implode('</li>', $links);
// 配列を連結して1つの文字列に
if ($echo) {
echo $result;
} else {
return $result;
}
}
示例10: master_array
/**
*
* @TODO document
*
*/
function master_array()
{
$left = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p>%s<br class="clear"/><p>%s</p></div></div>', __('Looking for something?', 'pagelines'), __('Use the form below to search the site:', 'pagelines'), pagelines_search_form(false), __("Still not finding what you're looking for? Drop us a note so we can take care of it!", 'pagelines'));
$middle = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p><ul>%s</ul></div></div>', __('Visit our friends!', 'pagelines'), __('A few highly recommended friends...', 'pagelines'), wp_list_bookmarks('title_li=&categorize=0&echo=0'));
$right = sprintf('<div class="widget"><div class="widget-pad"><h3 class="widget-title">%s</h3><p>%s</p><ul>%s</ul></div></div>', __('Archives', 'pagelines'), __('All entries, chronologically...', 'pagelines'), wp_get_archives('type=monthly&limit=12&echo=0'));
$this->master = array('left' => array('name' => 'MoreFoot Left', 'description' => __('Left sidebar in morefoot section.', 'pagelines'), 'default' => $left), 'middle' => array('name' => 'MoreFoot Middle', 'description' => __('Middle sidebar in morefoot section.', 'pagelines'), 'default' => $middle), 'right' => array('name' => 'MoreFoot Right', 'description' => __('Right sidebar in morefoot section.', 'pagelines'), 'default' => $right));
}
示例11: asdf_archive
function asdf_archive()
{
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php
echo bloginfo('stylesheet_directory');
?>
/jsddm.js"></script>
<div class="widget"><div class="asdf_archive">
<h1 class="widget-title">ARCHIVE</h1>
<img src="<?php
echo bloginfo('stylesheet_directory');
?>
/media/pfeil_hellgrau_archiv.png" >
<ul class="jsddm">
<li><a href="">WÄHLE DEN MONAT</a>
<ul><?php
wp_get_archives('type=monthly&format=html&show_post_count=0');
?>
</ul>
</li>
</ul>
</div></div>
<?php
}
示例12: archives_shortcode
function archives_shortcode($attr)
{
if (is_feed()) {
return '[archives]';
}
global $allowedposttags;
$default_atts = array('type' => 'postbypost', 'limit' => '', 'format' => 'html', 'showcount' => false, 'before' => '', 'after' => '', 'order' => 'desc');
extract(shortcode_atts($default_atts, $attr));
if (!in_array($type, array('yearly', 'monthly', 'daily', 'weekly', 'postbypost'))) {
$type = 'postbypost';
}
if (!in_array($format, array('html', 'option', 'custom'))) {
$format = 'html';
}
if ('' != $limit) {
$limit = (int) $limit;
}
$showcount = (bool) $showcount;
$before = wp_kses($before, $allowedposttags);
$after = wp_kses($after, $allowedposttags);
// Get the archives
$archives = wp_get_archives('type=' . $type . '&limit=' . $limit . '&format=' . $format . '&echo=0&show_post_count=' . $showcount . '&before=' . $before . '&after=' . $after);
if ('asc' == $order) {
$archives = implode("\n", array_reverse(explode("\n", $archives)));
}
// Check to see if there are any archives
if (empty($archives)) {
$archives = '<p>' . __('Your blog does not currently have any published posts.', 'jetpack') . '</p>';
} elseif ('option' == $format) {
$archives = "<select name='archive-dropdown' onchange='document.location.href=this.options[this.selectedIndex].value;'><option value='" . get_permalink() . "'>--</option>" . $archives . "</select>";
} elseif ('html' == $format) {
$archives = '<ul>' . $archives . '</ul>';
}
return $archives;
}
示例13: 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;
}
示例14: avia_dummy_widget
function avia_dummy_widget($number)
{
switch ($number) {
case 1:
$title = apply_filters('widget_title', __('Interesting links', 'avia_framework'));
?>
<section class='widget'>
<h3 class='widgettitle'><?php
echo $title;
?>
</h3>
<span class='minitext'><?php
_e('Here are some interesting links for you! Enjoy your stay :)', 'avia_framework');
?>
</span>
</section>
<?php
break;
case 4:
$title = apply_filters('widget_title', __('Archive', 'avia_framework'));
echo "<section class='widget widget_archive'>";
echo "<h3 class='widgettitle'>" . $title . "</h3>";
echo "<ul>";
wp_get_archives('type=monthly');
echo "</ul>";
echo "<span class='seperator extralight-border'></span></section>";
break;
case 3:
$title = apply_filters('widget_title', __('Categories', 'avia_framework'));
echo "<section class='widget widget_categories'>";
echo "<h3 class='widgettitle'>" . $title . "</h3>";
echo "<ul>";
wp_list_categories('sort_column=name&optioncount=0&hierarchical=0&title_li=');
echo "</ul>";
echo "<span class='seperator extralight-border'></span></section>";
break;
case 2:
$title = apply_filters('widget_title', __('Pages', 'avia_framework'));
echo "<section class='widget widget_pages'>";
echo "<h3 class='widgettitle'>" . $title . "</h3>";
echo "<ul>";
wp_list_pages('title_li=&depth=-1');
echo "</ul>";
echo "<span class='seperator extralight-border'></span></section>";
break;
case 5:
$title = apply_filters('widget_title', __('Bookmarks', 'avia_framework'));
echo "<section class='widget widget_archive'>";
echo "<h3 class='widgettitle'>" . $title . "</h3>";
echo "<ul>";
wp_list_bookmarks('title_li=&categorize=0');
echo "</ul>";
echo "<span class='seperator extralight-border'></span></section>";
break;
}
}
示例15: thesis_archives_template
function thesis_archives_template()
{
echo "\t\t\t\t\t<h3 class=\"top\">" . __('By Month:', 'thesis') . "</h3>\n";
echo "\t\t\t\t\t<ul>\n";
wp_get_archives('type=monthly');
echo "\t\t\t\t\t</ul>\n";
echo "\t\t\t\t\t<h3>" . __('By Category:', 'thesis') . "</h3>\n";
echo "\t\t\t\t\t<ul>\n";
wp_list_categories('title_li=0');
echo "\t\t\t\t\t</ul>\n";
}