Internet Marketing
Bel ons vandaag nog: 06 101 654 12

How to limit the amount of months in the WordPress Archive widget

This will show you how to limit the amount of months in the WordPress Archive widget and as a bonus I will tell you how to add some HTML under the Archive Widget, for example a text of ‘Click to see all posts’.

Change the amount of months

For this we need to change wp_get_archives() and this is located in wp-includes/general-template.php. Go to the rootfolder (eg with Filezilla) of your website and go to public_html/wp-includes/ and open the file: general-template.php. Look for the code:

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

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

Set

'type' => 'monthly', 'limit' => '6', 
wordpress archive widget

Example of an Archive Widget with maximum of six months. below the archives a custom text what says “Click here for all the posts”

to six or to whatever amount you wish. Also see the image above.

Add HTML to Archive Widget

For this we need to change the “the_widget()” and this is located in wp-includes/default-widgets.php Open this file and look for something that looks like this:

<?php } else { ?>

<ul>
		<?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?>
      		</ul>

Here you can put some html.

<?php } else { ?>

<ul>
		<?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?>

<li><a href="https://www.furore-internetmarketing.nl/#">Overzicht van alle berichten</a></li>

               
		</ul>

Hope this post was helpfull to you. And sorry for my English, I’m not a native English speaker 🙂

 

The following two tabs change content below.
Furore Internet Marketing zorgt altijd voor goede resultaten. Neem contact met ons op voor de mogelijkheden.

Laatste berichten van Furore Internet Marketing (toon alles)

Geef een reactie