我最近购买了一个WordPress主题,可以对照片进行精美的画廊展示,并且在主页上出现了以下错误。
警告:在第36行的/home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php中将其除以
警告:在第48行的/home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php中除以零
以下是第50行的代码 - /**/
的行是麻烦的。任何帮助表示赞赏!
<?php
global $postgallery;
$show = $postgallery->get_post_option('show');
$arr = $postgallery->get_post_option('show_'.$show);
$arr = explode(",", $arr);
$arr = (array)$arr;
//$myterms = get_terms('dt_gallery_cat');
$myterms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy'=> 'dt_gallery_cat'));
$images = array();
global $term, $h;
foreach ($myterms as $term)
{
if ($show == "all")
{
}
elseif ($show == "only")
{
if ( !in_array( $term->term_id, $arr ) )
continue;
}
elseif ($show == "except")
{
if ( in_array( $term->term_id, $arr ) )
continue;
}
$term->pic = wp_get_attachment_image_src( $term->image_id, 'full' );
$k = $term->pic[1] / $term->pic[2];
/**/$term->pic = $term->pic[0];/**/
$size = taxonomy_get_size( $term->term_id );
if ($size == "s")
$w = 220;
if ($size == "m")
$w = 460;
if ($size == "l")
$w = 700;
/**/$h = ceil($w / $k);/**/
$term->pic = get_template_directory_uri().'/thumb.php?src='.$term->pic.'&w='.$w.'&h='.$h.'&zc=1';
答案 0 :(得分:2)
如果您添加一些代码来检查值是否为零,则应该停止执行此操作,但可能存在更大的问题。
if ( $term->pic[1] == 0 || $term->pic[2] == 0 ) return
和/或
$h = ( $w > 0 && $k > 0 ) ? ceil($w / $k) : 0;
这些值可能不应该为零,因此可能会出现其他问题。也许您的图片不是代码可读的格式......或者您尚未上传任何