0

Im trying to create custom text for the archive links in my sidebar. Right now it prints it but it comes out as regular text - i'm trying to make the full text output into the link.

so "+ Trip {archive-link}" should be the link text

<?php wp_get_archives( array( 'type' => 'yearly', 'before' => '<li class="CAPS source-bold"><span class="plus">+</span> Trip ','after' => '</li>', 'format' => 'custom', ) ); ?>

any help would be greatly appreciated!

1 Answer 1

1

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='$url'>"
                   . "<span class='plus'>+</span> Trip $text"
                   . '</a></li>';
    }
    return $link_html;
}, 10, 6);

Then, in your template:

<?php wp_get_archives (['type' => 'yearly', 'format' => 'with_plus']) ?>

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.