doutang6819 2015-11-13 20:55
浏览 18
已采纳

WP Catatable致命错误

I'm getting the following error on my site, but only on the live version. The local version is just fine. PHP versions are the same, but is there a particular module in the php.ini file that should be turned on? I'm not sure where to look to fix this problem.

Catchable fatal error: Object of class WP_Error could not be converted to string in /var/www/vhosts/qhxh-vznq.accessdomain.com/httpdocs/wp-content/themes/digiday-careers/content-single-job.php on line 184

Below is where the error is occurring:

 <?php if (!empty($categories)) : ?>
    <div class="job-sidebar-info-block industry">
        <div class="title">Industry</div>
        <?php foreach ($categories as $category) : ?>
            <?php if (class_exists('WP_Job_Manager_Cat_Colors')) : ?>
                <p>
                    <a href="<?php echo get_term_link($category, 'job_listing_category'); ?>" class="job-category <?php echo $category->slug; ?>"><?php echo $category->name; ?>
                    </a>
                </p>
            <?php else : ?>
                <p>
                    <a href="<?php echo get_term_link($category, 'job_listing_category'); ?>">
                        <i class="icon-book-open"></i> 
                        <?php echo $category->name; ?>
                    </a>
                </p>
            <?php endif; ?>
        <?php endforeach; ?>
        </div>
 <?php endif; ?>
  • 写回答

1条回答 默认 最新

  • dsm17496 2015-11-13 21:43
    关注

    Replace the above code you mentioned with this code

    <?php if(!empty($categories)):?>
        <div class="job-sidebar-info-block industry">
            <div class="title">Industry</div>
            <?php foreach ( $categories as $category ) : ?>
                <?php if ( class_exists( 'WP_Job_Manager_Cat_Colors' ) ) : ?>
                    <p><a href="<?php echo is_wp_error( get_term_link( $category, 'job_listing_category' )); ?>" class="job-category <?php echo $category->slug; ?>"><?php echo $category->name; ?></a></p>
                <?php else : ?>
                    <p><a href="<?php echo is_wp_error(get_term_link( $category, 'job_listing_category' )); ?>"><i class="icon-book-open"></i> <?php echo $category->name; ?></a></p>
                <?php endif; ?>
            <?php endforeach; ?>
        </div>
     <?php endif;?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?