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

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

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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742312733a4420223.html

相关推荐

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

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

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信