Catchable fatal error: Object of class WP_Error could not be converted to string


#1

Why am I getting the fatal error while using woocommerce_before_main_content?

Course link - https://code.tutsplus.com/courses/developing-a-woocommerce-theme/lessons/adding-image-links-to-departments

<a href="
****Catchable fatal error: Object of class WP_Error could not be converted to string in F:\xampp\htdocs\wp_playground\wp-content\themes\tutsplus-woocommerce-store\functions.php on line 139

I think this is caused since I don’t have any taxonomy in my theme but I created one and still getting the same error. In course also you didn’t create any taxonomy. Any suggestions?

Here is my code:

    //home page header
    function tutsplus_home_page_category_links(){
	  
    if(is_shop()){ ?>

	<div class="product-cat-links full-width clear">

		<div class="one-third left">
			<a href="<?php echo get_term_link('Fitness', 'product_cat'); ?>">
				<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/adidas.jpg">
			</a>
			<h3><a href="<?php echo get_term_link('Fitness', 'product_cat'); ?>">Fitness</a></h3>
		</div>

		<div class="one-third left">
			<a href="<?php echo get_term_link('Bags', 'product_cat'); ?>">
				<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/bag.jpg">
			</a>
			<h3><a href="<?php echo get_term_link('Bags', 'product_cat'); ?>">Bags</a></h3>
		</div>

		<div class="one-third right">
			<a href="<?php echo get_term_link('Music', 'product_cat'); ?>">
				<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/music.jpg">
			</a>
			<h3><a href="<?php echo get_term_link('Music', 'product_cat'); ?>">Music</a></h3>
		</div>

	</div>

      <?php }
         }
        add_action('woocommerce_before_main_content', 'tutsplus_home_page_category_links');

#2

Any ideas about this @rachelmccollin?