0

I want to use the [archives type=yearly] short code on a side bar widget so that people can click on links and see posts for the year. But this is the result I'm getting:

enter image description here

This is what I'm doing in the Widgets Editor:

And I added add_filter( 'widget_text', 'do_shortcode' ); to wp-content/themes/twentysixteen/functions.php.

I also get a similar problem when pasting the [archives] into a page or post. The website just renders it at [archives].

If I enter a shortcode like [gallery], I see a gallery.

So the problem is with the [archives] short code.

What am I doing wrong?

enter image description here

1 Answer 1

0

I don't know or understand why, but I pasted this into wp-content/themes/twentysixteen/functions.php and it worked:

function wpse61674_archives_shortcode_cb( $atts ) {
    return '<h2 class="widget-title">Archives</h2><ul>'.wp_get_archives(array('format'=>'html','echo'=>false,'type'=>'yearly')).'</ul>';
}
add_shortcode( 'archives', 'wpse61674_archives_shortcode_cb' );

I found this code somewhere on the internet, but it wasn't part of the wordpress documentation on archives shortcode.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.