最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Warning: printf(): Too few arguments in helpers.php file

programmeradmin4浏览0评论

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>

发布评论

评论列表(0)

  1. 暂无评论