Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 96609

segrogan on "[Theme: Twenty Fourteen] Change archive periodicity and show post count"

$
0
0

Am setting up websites for students to use during a semester and would like the archive listing to be by the week and to display a post count. Reviewed several forum entries on this and 'what works' seems to differ and I suppose that is due to differing themes.

I have reviewed this: Codex Function Reference/wp get archives

I looked in sidebar.php under the Twenty Fourteen theme and did not see anything that seemed to do with displaying an archive.

In wp-includes/general-temp I found this code:

function wp_get_archives($args = ' ') {
	global $wpdb, $wp_locale;

	$defaults = array(
		'type' => 'monthly', 'limit' => '',
		'format' => 'html', 'before' => '',
		'after' => '', 'show_post_count' => false,
		'echo' => 1, 'order' => 'DESC',
	);

I changed to this: 'wp_get_archives('type=weekly&show_post_count=true')'

Nothing happened.

I searched the files for "archives" and found an archives.php in wp-content/plugins/jetpack/modules/shortcodes/archives.php
which I have no idea what to do with:

<?php

/*
 * Archives shortcode
 * @author bubel & nickmomrik
 * [archives limit=10]
 */

add_shortcode( 'archives', '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( array(
		'type'            => $type,
		'limit'           => $limit,
		'format'          => $format,
		'echo'            => false,
		'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;
}

Do not have any experience other than pasting in a few pieces of copied code here and there and figured it would be best to ask before I mess things up.

thanks

[Moderator Note: Please post code between backticks (not single quotes) or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]


Viewing all articles
Browse latest Browse all 96609

Trending Articles