true,
'ignore_sticky_posts' => true,
'post_type' => 'post'
) );
if ( !$query->have_posts() )
return __( '没有文章。', 'Bing' );
$month = null;
$heading = Bing_get_main_list_title_tag();
$code = '';
while ( $query->have_posts() ) {
$query->the_post();
if ( ( $current_month = get_the_date( 'Y-m' ) ) != $month ) {
if ( $month )
$code .= '';
$month = $current_month;
$code .= "<$heading>$month$heading>
";
}
$url_attr = esc_url( get_permalink() );
$day = get_the_date( 'd' );
$title = get_the_title();
$code .= "- $day - $title
";
}
$code .= '
';
wp_reset_postdata();
return $code;
}
add_shortcode( 'archives', 'Bing_shortcode_archives' );
/**
* 标签云简码
*/
function Bing_shortcode_tags() {
return wp_tag_cloud( 'echo=0&number=0' );
}
add_shortcode( 'tags', 'Bing_shortcode_tags' );
/**
* 友情链接简码
*
* @since Beginning 4.1.0
*/
function Bing_shortcode_links( $atts, $content, $shortcode ) {
$pairs = array( 'menu' => null );
$atts = shortcode_atts( $pairs, $atts, $shortcode );
if ( !$items = wp_get_nav_menu_items( $atts['menu'] ) )
return __( '没有找到友情链接。', 'Bing' );
$code = '';
foreach ( $items as $item ) {
$name = get_the_title( $item );
$link = $item->url;
$domain = parse_url( $link, PHP_URL_HOST );
$icon = Bing_get_website_favicon( $domain );
$title = '
';
$title .= '' . $name . '';
$title = '';
if ( empty( $item->post_content ) )
$description = '';
else
$description = '' . $item->post_content . '';
$atts = Bing_render_attributes( array_filter( array(
'href' => $link,
'class' => 'link-box',
'title' => $item->attr_title,
'target' => $item->target,
'rel' => $item->xfn
) ) );
$code .= "- {$title}{$description}
";
}
$code .= '
';
return $code;
}
add_shortcode( 'links', 'Bing_shortcode_links' );
// End of page.