質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

1548閲覧

「zillah」というテーマでエラーメッセージ表示

tsubasa0528

総合スコア12

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2017/06/05 01:34

###前提・実現したいこと
ローカル環境で開発している社内HPのテーマの警告を非表示させたい。
現在、「zillah」というテーマ社内HPの改修を行っている者です。
エラー表示が出てしまいます。どなたかお力かしていただけますか?

###発生している問題・エラーメッセージ

Warning: sprintf(): Too few arguments in C:\xampp\htdocs\syanai\wp-content\themes\zillah\inc\template-tags.php on line 146 というエラーが発生します。

###該当のソースコード

<?php /** * Custom template tags for this theme. * * Eventually, some of the functionality here could be replaced by core features. * * @package zillah */ if ( ! function_exists( 'zillah_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function zillah_posted_on() { $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( /* translators: s: post date */ esc_html_x( 'Posted on %s', 'post date', 'zillah' ), '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' ); $byline = sprintf( /* translators: s: post author */ esc_html_x( 'by %s', 'post author', 'zillah' ), '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' ); echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. } endif; if ( ! function_exists( 'zillah_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function zillah_entry_footer() { // Hide category and tag text for pages. if ( 'post' === get_post_type() ) { $zillah_tags_show = get_theme_mod( 'zillah_tags_show', false ); if ( $zillah_tags_show === true || is_customize_preview() ) { /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'zillah' ) ); if ( $tags_list ) { /* translators: 1: tags */ printf( '<span class="tags-links' . ( $zillah_tags_show === false && is_customize_preview() ? ' zillah-only-customizer' : '' ) . '">' . esc_html__( 'Tagged %1$s', 'zillah' ) . '</span>', $tags_list ); // WPCS: XSS OK. } } } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( ' Edit %s', 'zillah' ), the_title( '<span class="screen-reader-text">"', '"</span>', false ) ), '<span class="edit-link">', '</span>' ); } endif; /** * Returns true if a blog has more than 1 category. * * @return bool */ function zillah_categorized_blog() { $all_the_cool_cats = get_transient( 'zillah_categories' ); if ( false === $all_the_cool_cats ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'zillah_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so zillah_categorized_blog should return true. return true; } else { // This blog has only 1 category so zillah_categorized_blog should return false. return false; } } /** * Flush out the transients used in zillah_categorized_blog. */ function zillah_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'zillah_categories' ); } add_action( 'edit_category', 'zillah_category_transient_flusher' ); add_action( 'save_post', 'zillah_category_transient_flusher' ); if ( ! function_exists( 'zillah_posted_date' ) ) : /** * Prints HTML with meta information for the current post-date. */ function zillah_posted_date() { $show_updated = get_theme_mod( 'zillah_show_updated', false ); $time_string = '<time class="entry-date published updated" datetime="%1$s" itemprop="dateModified">%2$s</time><meta itemprop="datePublished" content="%2$s">'; if ( ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time><time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time><meta itemprop="datePublished" content="%4$s">'; if ( (bool) $show_updated === true ) { $time_string = '%6$s <time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time> - %5$s <time datetime="%3$s" itemprop="dateModified">%4$s</time><meta itemprop="datePublished" content="%4$s">'; } } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ), esc_html__( 'Updated:', 'zillah' ), esc_html__( 'Posted:', 'zillah' ) ); (146行目) $posted_on = sprintf( '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string. '</a>' ); echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK. } endif; if ( ! function_exists( 'zillah_category' ) ) : /** * Prints HTML with meta information for the category. */ function zillah_category() { $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'zillah' ) ); if ( $categories_list ) { printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', _x( 'Categories', 'Used before category names.', 'zillah' ), $categories_list ); } } endif; if ( ! function_exists( 'zillah_comments_number' ) ) : /** * Prints comments number. */ function zillah_comments_number() { echo '<span class="alt-comments-number">'; $comments_number = get_comments_number(); if ( 1 === $comments_number ) { /* translators: %s: post title */ printf( _x( '1 Comment', 'comments title', 'zillah' ) ); } else { printf( /* translators: 1: number of comments, 2: post title */ _nx( '%1$s Comment', '%1$s Comments', $comments_number, 'comments title', 'zillah' ), number_format_i18n( $comments_number ) ); } echo '</span>'; } endif;

###補足情報(言語/FW/ツール等のバージョンなど)
php言語 XAMPP使用

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

sprintf()は第1引数に与えられた文字列に対して第2引数以降で変換表示する文字列の指定をしていきます。(リンク先参照)

146行目を拝見しますと、第2引数があてられていません。それがエラーメッセージの意味です。
(フォーマットの変換用の文字列の個数と第2引数以降の数があっていない)

ただ、第1引数にはフォーマット文字列が含まれていないようですので、sprintf()自体不要なのではないでしょうか?

PHP

1$posted_on = '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string. '</a>' ; 2echo '<span class="posted-on">' . $posted_on . '</span>';

※get_permalink()はおそらく何かしらのリンクURLを取得していると思いますがその内容によります。

投稿2017/06/05 02:02

編集2017/06/05 02:04
m.ts10806

総合スコア80765

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tsubasa0528

2017/06/05 02:06

回答ありがとうございました。 エラー表示がなくなりました。 また、エラーの理由も詳しく載せていただきありがとうございました。 参考にさせていただきます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問