Custom link text wp_get_archive link

I think the simplest way would be to use the get_archives_link filter. For example: add_filter (‘get_archives_link’, function ($link_html, $url, $text, $format, $before, $after) { if (‘with_plus’ == $format) { $link_html = “<li class=”CAPS source-bold”><a href=”https://wordpress.stackexchange.com/questions/170116/$url”>” . “<span class=”plus”>+</span> Trip $text” . ‘</a></li>’; } return $link_html; }, 10, 6); Then, in your template: <?php wp_get_archives ([‘type’ … Read more

Make post title active

Your current code relies on time travel to work: $IDOutsideLoop = $post->ID; global $post; Specifically the first line is peering into the future, how can it know what $post->ID is if it’s undeclared? The fix is global $post;, but when the computer gets to that line, it’s too late global $post; $IDOutsideLoop = $post->ID; If … Read more

What do I need to style for the page after wp_get_archives?

According to the Template Hierarchy, archives are usually displayed using the theme’s archive.php file, although other template pages might be used instead (see the image on that page). So, you would need to change your theme’s archive.php file, or change the font-page.php or home.php template (again, see the image on the above page). I suspect … Read more

remove 2014 from wp_get_archives

The only filter i could find inside the wp_get_archives function is for displaying the links. Based on the get_archives_link filter, this should work, use it in your functions.php file: $archive_year = 0; add_filter(‘get_archives_link’,’wp_get_archive_grouped_by_year’,10,2); function wp_get_archive_grouped_by_year($link_html) { global $archive_year; //Get the year from the link(probably better if you change this to regexp) $year_new = explode(‘ ‘, … Read more

Get archives as array

If you look at wp_get_archives() you will notice that the link is generated by get_archives_link(). That function supplies a filter that will allow you to replace the parens. This is fairly crude but does work. function archive_link_wpse_183665($link) { $pat=”|\(([^)])\)</li>|”; // preg_match($pat,$link,$matches); // var_dump($matches); $link = preg_replace($pat,'[$1]’,$link); return $link; } add_filter( ‘get_archives_link’, ‘archive_link_wpse_183665’ );

How to list articles by year based on url?

Avoid using query_posts() Please don’t use query_posts(‘posts_per_page=10’); in your date.php template file as it will override the main query instance and thus affect the main loop. This can truly ruin the day! If you need to modify e.g. the posts_per_page for the main date query, use the pre_get_posts action to modify the query variables, before … Read more