taxnomy.php使用によるエラー表示について
-
○質問の主旨
このエラーの意味は何でしょうか?
引数が足りないようなことが書いてあるように思えますが、
どこに何を加えたらいいのかよく分かりません。taxonomy.phpとそれにかかわるfunctions.phpの一部を
貼り付けておきます。詳しいことをご存知の方がいらっしゃいましたら、
ご教示願います。Warning: Missing argument 1 for add_class(), called in
C:\xampp\htdocs\wordpress3\wp-content\themes\Green\taxonomy.php on line 20 and defined in
C:\xampp\htdocs\wordpress3\wp-content\themes\Green\functions.php on line 693 Call Stack #TimeMemoryFunctionLocation 10.0006138320{main}( )..\index.php:0 20.0010140264require( ‘
C:\xampp\htdocs\wordpress3\wp-blog-header.php’ )..\index.php:17 30.272713091840require_once( ‘
C:\xampp\htdocs\wordpress3\wp-includes\template-loader.php’ )..\wp-blog-header.php:16 40.277713208296include( ‘
C:\xampp\htdocs\wordpress3\wp-content\themes\Green\taxonomy.php’ )..\template-loader.php:47 50.326613323616add_class( )..\taxonomy.php:20 alpha”>○質問の補足
固定ページ(page.php)の下に投稿のタイプを分けるために
taxonomy.phpを設置したら、ちょうど上記のエラーメッセージが表示されました。現在、私が作成しているWebサイトの階層構造は、
以下の通りです。ホーム(top.php)
↓
製品一覧(page.php)
↓
製品の種類(taxonomy.php)
↓
各製品のページ(single-products.php)○参考文献
基礎からのWordPress Part6 Chapter24
(アマゾンの短縮コード)
http://goo.gl/JQdtt0サンプルコードは自分で加工する必要もなく
大方は表示されてしまうため、コードのどこにエラーの要素が
あるのか分かりません以上、お詳しい方よろしくお願い申し上げます。
○コード
(taxonomy.php)
get_header(); ?>
<!– taxonomy.php –>
<div class=”grid_9 push_3″ id=”main”><?php if (have_posts()) : /* ループ開始 */
while (have_posts()) : the_post(); ?>
<article class=”grid_3 box-link <?php echo add_class(); /* Green 独自関数 – テーマ用のクラスを付ける */ ?>”>
<div class=”box-s-top”></div>
<div class=”box-s-middle equal-height”><hgroup>
<h3><?php the_title(); /* タイトル */ ?></h3><h4 class=”subtitle”>
<?php if( get_post_meta($post -> ID,’sub-title’) ) : /* カスタムフィールドを利用したサブタイトル */
echo get_post_meta($post -> ID,’sub-title’, true);
else: ?>
Subtile
<?php endif; ?>
</h4>
</hgroup><?php if(has_post_thumbnail()): /* アイキャッチ画像 */ ?>
<?php the_post_thumbnail(); ?>
<?php else: ?>
<img src=”<?php echo get_template_directory_uri(); ?>/images/default.jpg” alt=”” />
<?php endif; ?>
<div class=”excerpt”>
<?php echo my_excerpt(60); /* Green 独自関数 – 半角60文字抜粋を表示する */ ?>
</div><p class=”rigft-align link”>
“>詳しく見る
</p></div>
<div class=”box-s-bottom”></div></article>
<?php endwhile;
else : ?>
<div class=”box-top”></div>
<article class=”box-middle post”><h3>Not Found</h3>
<p>Sorry, but you are looking for something that isn’t here.</p>
</article>
<div class=”box-bottom”></div><?php endif;
if (function_exists(‘wp_pagenavi’)): /* ページャープラグイン wp_pagenavi用 */
wp_pagenavi();
else:
if ( $wp_query->max_num_pages > 1 ) : /* 複数ページ用のナビゲーション */ ?>
<nav class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« PREV’); ?></div>
<div class=”alignright”><?php previous_posts_link(‘NEXT »’); ?></div>
</nav><?php endif;
endif; ?>
</div>
<!– main –>
<!– /taxonomy.php –><?php get_sidebar(); ?>
<?php get_footer(); ?>(functions.php)
/**
* taxonomy.php、single-product で使用 – 左端には alpha、右端には omega というクラスをつけるオリジナル関数
*/function add_class($obj){
if( !$obj ){
global $wp_query;
$obj = $wp_query;
}$current_post = $obj -> current_post;
if( ($current_post % 3 ) === 0 ){
$class = ‘alpha’;
}elseif( ($current_post % 3 ) === 2 ){
$class = ‘omega’;
}else{
$class = ”;
}return $class;
}
- トピック「taxnomy.php使用によるエラー表示について」には新たに返信することはできません。