linccce

Error while inserting woocommerce theme

Jun 15th, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. ### Using cherry framework with child theme, in functions.php trying to override woocommerce template.
  2.  
  3. add_filter( 'template_include', 'wc_template_check' );
  4. function wc_template_check( $template ) {
  5.     if ( is_shop() ){
  6.         return get_stylesheet_directory() . '/woocommerce/content-product_cat.php';
  7.     }
  8. }
  9.  
  10. ### as a result I get this error.
  11.  
  12. /*  Catchable fatal error: Object of class WP_Error could not be converted to string in F:\xampp\htdocs\estlita.lt\wp-content\themes\estlita\woocommerce\content-product_cat.php on line 38
  13. *   Call Stack #TimeMemoryFunctionLocation 10.0004134752{main}( )...\index.php:0 20.0007136696
  14. *   require( 'F:\xampp\htdocs\estlita.lt\wp-blog-header.php' )...\index.php:17 31.421541508992
  15. *   require_once( 'F:\xampp\htdocs\estlita.lt\wp-includes\template-loader.php' )...\wp-blog-header.php:16 41.458441756752
  16. *   include( 'F:\xampp\htdocs\estlita.lt\wp-content\themes\estlita\woocommerce\content-product_cat.php' )...\template-loader.php:74
  17. */
  18.  
  19. ### On line 38 there is such code:
  20. ### <a href="<?php echo get_term_link( $category->slug, 'product_cat' ); ?>">
  21.  
  22. ### On Cherry Framework there is Custom functions files /includes/custom-functions.php
  23.  
  24. ### Maybe this somehow messes up get_term_link.
  25.  
  26.     // Product title length
  27.     add_filter( 'the_title', 'tm_product_title_length', 10, 2 );
  28.     function tm_product_title_length($title) {
  29.         if (is_admin())
  30.             return $title;
  31.         global $post, $woocommerce_loop;
  32.         $post_type = get_post_type( $post );
  33.         if ($woocommerce_loop) {
  34.             if ( 'product' == $post_type ) {
  35.                 $length_limit = intval( of_get_option('cat_title_length_limit') );
  36.                 if ( "" != $length_limit ) {
  37.                     $words = explode(' ', $title, ($length_limit + 1));
  38.                     if( count($words) > $length_limit ) {
  39.                         array_pop($words);
  40.                         $title = implode(' ', $words) . '... ';
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.         return $title;
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment