Wordpress Archives widget - html output setup

I still snuggled into Wordpress, it seems. I added the Archives widget to my sidebar and again, the html output is shit, it basically has this structure:

<li><a href="somelink">text</a> - (# of posts)</li>

I want to convert it to:

<li><a href="somelink">text <small># of posts</small></a>

Unlike plugins, I could not find a line that creates html output on php pages proposed / mentioned by the wordpress community, namely functions.php, widgets.php and default-widgets.php

I searched for all possible combinations of keywords on this subject, and I could not find something important.

All help is appreciated.

Hi

G.Campos

+3
source share
1 answer

general-template.php. wp_get_archives get_archives_link. wp_get_archives, , $text. $ , get_archives_link. :

$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count )
   $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;

- :

$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count )
   $text= $text.'&nbsp;<small>'.$arcresult->posts.'</small>';

. , .

: <small> - , get_archives_link. , $text $title:

$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
$title = $text;
if ( $show_post_count )
   $text= $text.'&nbsp;<small>'.$arcresult->posts.'</small>';
$output .= get_archives_link($url, $text, $format, $before, $after, $title);

get_archives_link:

function get_archives_link($url, $text, $format = 'html', $before = '', $after = '', $title = '') {
    $text = wptexturize($text);

    if($title == '')
        $title = $text;

    $title_text = esc_attr($title);
    $url = esc_url($url);

    if ('link' == $format)
        $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
    elseif ('option' == $format)
        $link_html = "\t<option value='$url'>$before $text $after</option>\n";
    elseif ('html' == $format)
        $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
    else // custom
        $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";

    $link_html = apply_filters( "get_archives_link", $link_html );

    return $link_html;
}
+2

Source: https://habr.com/ru/post/1792338/


All Articles