admin管理员组

文章数量:1333428

So I'm getting the following error Warning: printf(): Too few arguments in /lib/helpers.php on line 34

So line 34 is 'class' => []

// Define the read more url
function read_more_url() {

    // Grab the posts link and title
    echo '<a href="' . esc_url(get_the_permalink()) . '" title="' . the_title_attribute(['echo' => false]) . '">';

    printf(
        // Filters text content and strips out disallowed HTML
        wp_kses(
            __('Read more <span class="u-screen-reader-text">about %s</span>', 'Sema'),
            [
                'span' => [
                    'class' => []
                ]
            ]
        )
    );
}

Could someone tell me what I might be doing wrong? The echo is working correctly.

So I'm getting the following error Warning: printf(): Too few arguments in /lib/helpers.php on line 34

So line 34 is 'class' => []

// Define the read more url
function read_more_url() {

    // Grab the posts link and title
    echo '<a href="' . esc_url(get_the_permalink()) . '" title="' . the_title_attribute(['echo' => false]) . '">';

    printf(
        // Filters text content and strips out disallowed HTML
        wp_kses(
            __('Read more <span class="u-screen-reader-text">about %s</span>', 'Sema'),
            [
                'span' => [
                    'class' => []
                ]
            ]
        )
    );
}

Could someone tell me what I might be doing wrong? The echo is working correctly.

Share Improve this question asked Jun 28, 2020 at 2:00 DevSemDevSem 2092 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Your printf statement awaits additional string argument which would be substituted instead of %s:

    printf(
        // Filters text content and strips out disallowed HTML
        wp_kses(
            __('Read more <span class="u-screen-reader-text">about %s</span>', 'Sema'),
            [
                'span' => [
                    'class' => []
                ]
            ]
        ), "some subject"
    );

This example would produce the following output:

Read more <span class="u-screen-reader-text">about some subject</span>

本文标签: theme developmentWarning printf() Too few arguments in helpersphp file