• I just installed Dave’s Live Search for use with my custom theme but the JavaScript console complains: “Uncaught ReferenceError: _ is not defined”. If I switch over to the default TwentyFourteen theme, however, the erorr goes away.

    I tried running wp_script_is() from DavesWordPressLiveSearch::advanced_search_init() and it looks like the script *is* enqueued as it should be…

    A temporary fix appears to be to add “underscore” as a dependency of the “daves-wordpress-live-search” script as it is enqueued on lines 38 and 43 of class-daves-wordpress-live-search.php. Obviously, I’d like to figure out why Live Search works with other themes but not mine, though.

    Thanks in advance for your help!

    https://wordpress.org/plugins/daves-wordpress-live-search/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    I have excatly the same problem while adding the code below in my template.

    If I remove the code, everything is working fine. Any idea?

    <?php echo _e( "Goes well with...", "shiseido" ); ?><br/><br/>
    
    		<?php
    		$postperpage = 5;
    		$paged = 1;
    		$type = array('shiseido_products');
    		$taxonomy = 'shiseido-category';
    
    		$args=array(
    			'post_type' => $type,
    			'post_status' => 'publish',
    			'paged' => $paged,
    			'posts_per_page' => $postperpage,
    			'ignore_sticky_posts'=> 1,
    			'post__not_in' => array(get_the_id()),
    			'tax_query' => array(
    					array(
    						'taxonomy' => $taxonomy,
    						'field' => 'id',
    						'terms' => array($in_cats),
    						'operator' => 'IN'
    					)
    				)
    		);
    
    		$temp = $wp_query;
    		$wp_query = null;
    		$wp_query = new WP_Query($args);
    		?>
    
    		<?php if ( $wp_query->have_posts() ) { ?>
    			<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    					<?php $category = get_the_category_bytax($post->ID, 'shiseido-line'); echo $category[0]->cat_name; ?><br/>
    					<?php the_title(); ?><br/>
    					<?php
    					$rows = get_field('shiseido_product_thumbnails' );
    					$first_row = $rows[0];
    					$first_row_image = $first_row['shiseido_product_main_thumbnail' ];
    					$image = wp_get_attachment_image_src( $first_row_image, '200x200' );
    					if ($image) { ?>
    						<img width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" src="<?php echo $image[0]; ?>" />
    					<?php } ?>
    
    				</a><br/>
    			<?php endwhile; ?>
    		<?php } ?>

    Ok I found something, changing $wp_query to another name (for example I used $wp_query_related) made it working for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Underscore Undefined When Using Custom Theme’ is closed to new replies.