Forum Replies Created

Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter Gabums

    (@gabums)

    Actually I got it saying “Array Array Array no Why Are Health Costs So High? no no_sidebar default default…” (I had the characters limited before so I didn’t see all this)

    It seems to be pulling the custom_field title, but surrounds it with strange characters.

    Thread Starter Gabums

    (@gabums)

    Hmm.. now it says “array array.” Maybe there are multiple of arrays within zn_meta_elements and that is causing it?

    add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
    function custom_fields_to_excerpts($content, $post) {
        $custom_field = get_post_meta($post->ID, 'zn_meta_elements', true);
        $content .= ' ' . ( is_array($custom_field) ? implode(' ', $custom_field) : $custom_field );
        return $content;
    }
    Thread Starter Gabums

    (@gabums)

    Good evening,

    I figured it out! One last question though and I’ll be on my way. I’ve used this code:

    add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
    function custom_fields_to_excerpts($content, $post, $query) {
        $custom_field = get_post_meta($post->ID, 'zn_meta_elements', true);
        $content .= " " . $custom_field;
        return $content;
    }

    In my functions.php file. I’ve also placed “zn_meta_elements” in custom fields to index in the plugin settings. When I do a search, where the excerpt is supposed to be, it says “array”. Any ideas on why that would be?

    Thank you again!

    Thread Starter Gabums

    (@gabums)

    Sure no problem! There seems to be two files associated with the search results page. Archive.php (according to the theme developers), and blog-default.php.

    Archive.php

    <?php get_header(); ?>
    <?php
    
    	if ( is_home() ) {
    		$blog_page_id = get_option( 'page_for_posts' );
    		global $wp_query;
    		$meta_fields = get_post_meta($blog_page_id, 'zn_meta_elements', true);
    		$meta_fields = maybe_unserialize($meta_fields);
    	}
    
    /*--------------------------------------------------------------------------------------------------
    	ACTION BOX AREA
    --------------------------------------------------------------------------------------------------*/
    
    	if ( isset ( $meta_fields['action_box_area'] ) && is_array ( $meta_fields['action_box_area'] ) ) {
    		zn_get_template_from_area ('action_box_area',$post->ID,$meta_fields);
    	}
    
    /*--------------------------------------------------------------------------------------------------
    	CONTENT AREA
    --------------------------------------------------------------------------------------------------*/
    
    	// Here will check if sidebar is enabled
    	$content_css = 'span12';
    	$sidebar_css = '';
    	$has_sidebar = false;
    	$mainbody_css = '';
    
    	// WE CHECK IF THIS IS NOT A PAGE FROM OUR THEME
    	if ( empty ( $meta_fields['page_layout'] ) || empty ( $meta_fields['sidebar_select'] ) ) {
    		if ( $data['archive_sidebar_position'] == 'left_sidebar' ) {
    			$content_css = 'span9 zn_float_right zn_content';
    			$sidebar_css = 'sidebar-left';
    			$has_sidebar = true;
    			$mainbody_css = 'zn_has_sidebar';
    		}
    		elseif ( $data['archive_sidebar_position'] == 'right_sidebar' ) {
    			$content_css = 'span9 zn_content';
    			$sidebar_css = 'sidebar-right';
    			$has_sidebar = true;
    			$mainbody_css = 'zn_has_sidebar';
    		}
    	}
    	// WE CHECK IF WE HAVE LEFT SIDEBAR
    	elseif ( $meta_fields['page_layout'] == 'left_sidebar' || ( $meta_fields['page_layout'] == 'default' && !empty ( $data['archive_sidebar_position'] ) && $data['archive_sidebar_position'] == 'left_sidebar' )   )
    	{
    		$content_css = 'span9 zn_float_right zn_content';
    		$sidebar_css = 'sidebar-left';
    		$has_sidebar = true;
    		$mainbody_css = 'zn_has_sidebar';
    	}
    	// WE CHECK IF WE HAVE RIGHT SIDEBAR
    	elseif ( $meta_fields['page_layout'] == 'right_sidebar' || ( $meta_fields['page_layout'] == 'default' && !empty ( $data['archive_sidebar_position'] ) && $data['archive_sidebar_position'] == 'right_sidebar' )  )
    	{
    		$content_css = 'span9 zn_content';
    		$sidebar_css = 'sidebar-right ';
    		$has_sidebar = true;
    		$mainbody_css = 'zn_has_sidebar';
    	}
    
    ?>
    
    	<section id="content">
    		<div class="container">
    
    			<div id="mainbody <?php echo $mainbody_css;?>">
    
    			<?php	
    
    				$columns = 1;
    
    				if ( !empty( $data['blog_style_layout'] ) ) {
    
    					$columns = $data['blog_style_layout'];
    
    				}
    
    				if ( $columns > 1 ) {
    					get_template_part( 'blog', 'columns' );
    				}
    				else {
    					get_template_part( 'blog', 'default' );
    				}
    			?>
    
    			</div><!-- end mainbody -->
    
    		</div><!-- end container -->
    <?php
    /*--------------------------------------------------------------------------------------------------
    	START CONTENT AREA
    --------------------------------------------------------------------------------------------------*/
    	if ( isset ( $meta_fields['content_main_area'] ) && is_array ( $meta_fields['content_main_area'] ) ) {
    		echo '<div class="container">';
    			zn_get_template_from_area ('content_main_area',$post->ID,$meta_fields);
    		echo '</div>';
    	}
    
    /*--------------------------------------------------------------------------------------------------
    	START GRAY AREA
    --------------------------------------------------------------------------------------------------*/
    
    	$cls = '';
    	if ( !isset ( $meta_fields['content_bottom_area'] ) || !is_array ( $meta_fields['content_bottom_area'] ) ) {
    		$cls = 'noMargin';
    	}
    
    	if ( isset ( $meta_fields['content_grey_area'] ) && is_array ( $meta_fields['content_grey_area'] ) ) {
    	echo '<div class="gray-area '.$cls.'">';
    		echo '<div class="container">';
    
    			zn_get_template_from_area ('content_grey_area',$post->ID,$meta_fields);
    
    		echo '</div>';
    	echo '</div>';
    	}
    
    /*--------------------------------------------------------------------------------------------------
    	START BOTTOM AREA
    --------------------------------------------------------------------------------------------------*/
    
    	if ( isset ( $meta_fields['content_bottom_area'] ) && is_array ( $meta_fields['content_bottom_area'] ) ) {
    		echo '<div class="container">';
    			zn_get_template_from_area ('content_bottom_area',$post->ID,$meta_fields);
    		echo '</div>';
    	}
    ?>
    	</section><!-- end content -->
    
    <?php get_footer(); ?>

    Blog-default.php

    <div class="row">
    
    	<div class="<?php echo $content_css; ?>">
    
    		 <div class="itemListView clearfix eBlog">
    
    			<div class="itemList">
    
    			<?php
    
    			if ( have_posts() ) :
    				while( have_posts() ){
    
    					the_post();
    
    					$image = '';
    
    					// Create the featured image html
    					if ( has_post_thumbnail(  ) && ! post_password_required() ) {
    
    						$thumb = get_post_thumbnail_id($post->ID);
    						$f_image = wp_get_attachment_url($thumb);
    						if ( !empty ( $f_image ) ) {
    							if ( isset( $data['sb_archive_use_full_image'] ) && $data['sb_archive_use_full_image'] == 'yes' )  {
    								$image = '<div class="zn_full_image"><a data-rel="prettyPhoto" href="'.$f_image.'" class="hoverBorder">'.get_the_post_thumbnail($post->ID ,'full-width-image').'</a></div>';
    							}
    							else {
    								$image = '<div class="zn_post_image"><a href="'.get_permalink().'" class="hoverBorder pull-left">'.get_the_post_thumbnail().'</a></div>';
    							}
    						}
    
    					}
    					elseif ( $data['zn_use_first_image'] == 'yes' && ! post_password_required()) {
    
    						$f_image =  echo_first_image();
    						if ( !empty ( $f_image ) ) {
    
    							if ( isset( $data['sb_archive_use_full_image'] ) && $data['sb_archive_use_full_image'] == 'yes' )  {
    								$feature_image = wp_get_attachment_url( $thumb );
    
    								$size = zn_get_size( 'sixteen' ,$has_sidebar , 30 );
    
    								$image = vt_resize( '', $f_image  , $size['width'] ,'' , true );
    								$image = '<div class="zn_full_image"><a data-rel="prettyPhoto" href="'.$feature_image.'" class="hoverBorder"><img class="shadow" src="'.$image['url'].'" alt=""/></a></div>';
    
    							}
    							else {
    
    								$image = vt_resize( '', $f_image  , 280,187 , true );
    								$image = '<a href="'.get_permalink().'" class="hoverBorder pull-left" style="margin-right: 20px;margin-bottom:4px;"><img class="shadow" src="'.$image['url'].'" alt=""/></a>';
    							}
    						}
    					}
    
    					?>
    
    					<div class="itemContainer post-<?php the_ID(); ?>"> 
    
    						<div class="itemHeader">
    							<h3 class="itemTitle">
    								<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
    							</h3>
    							<div class="post_details">
    								<span class="catItemDateCreated"><span class="icon-calendar"></span> <?php the_time('l, d F Y');?></span>
    								<span class="catItemAuthor"><?php echo __( 'by', THEMENAME );?> <?php the_author_posts_link(); ?></span>
    							</div><!-- end post details -->
    						</div><!-- end itemHeader -->
    
    						<div class="itemBody">
    							<div class="itemIntroText">
    							<?php
    								if ( preg_match('/<!--more(.*?)?-->/', $post->post_content) ) {
    									echo $image;
    									relevanssi_the_excerpt('');
    								}
    								else {
    									echo $image;
    									relevanssi_the_excerpt();
    								}
    							?>
    
    							</div><!-- end Item Intro Text -->
    							<div class="clear"></div>
    							<div class="itemReadMore">
    								<a class="readMore" href="<?php the_permalink(); ?>"><?php echo __( 'Read more...', THEMENAME );?></a>
    							</div><!-- end read more -->
    							<div class="clear"></div>
    						</div><!-- end Item BODY -->
    
    						<div class="clear"></div>
    					<?php	if (has_tag()) { ?>
    							<div class="itemTagsBlock">
    								<span class="icon-tags"></span>
    								<span><?php echo __( 'Tagged under:', THEMENAME );?></span>
    								<?php the_tags('');?>
    								<div class="clear"></div>
    							</div><!-- end tags blocks -->
    					<?php	}	?>	
    
    				</div><!-- end Blog Item -->
    				<div class="clear"></div>
    
    			<?php
    				}
    			else: ?>
    				<div class="itemContainer noPosts">
    					<p><?php echo __('Sorry, no posts matched your criteria.', THEMENAME ); ?></p>
    				</div><!-- end Blog Item -->
    				<div class="clear"></div>
    			<?php endif; ?>
    
    			</div><!-- end .itemList -->
    
    			<!-- Pagination -->
    			<?php zn_pagination(); ?>
    
    		</div><!-- end blog items list (.itemListView) -->
    
    	</div>
    
    </div>

    Thank you again so much for looking into this for me. It is really REALLY appreciated.

    Thread Starter Gabums

    (@gabums)

    Hi! Thanks for your quick response!

    My theme doesn’t have a search results template. The developer added the search code to the functions.php file

    add_filter('get_search_form', 'zn_search_form');
    if ( ! function_exists( 'zn_search_form' ) ) {
    	function zn_search_form($form) {
    	$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
    		<div class="zn_search_container">
    		<input title="' . __('Search for...',THEMENAME) . '" class="zn-inline-text" type="text" value="' . get_search_query() . '" name="s" id="s" />
    		<input class="square_button search_submit" type="submit" id="searchsubmit" value="a" /><div class="clear"></div>
    		</div>
    		</form>';
    
    		$form =	'			<div class="search">';
    		$form .=	'				<form id="searchform" action="' . home_url( '/' ) . '" method="get">';
    		$form .=	'					<input id="s" name="s" maxlength="20" class="inputbox" type="text" size="20" value="'. __( 'SEARCH ...', THEMENAME ).'" onblur="if (this.value==\'\') this.value=\''. __( 'SEARCH ...', THEMENAME ).'\';" onfocus="if (this.value==\''. __( 'SEARCH ...', THEMENAME ).'\') this.value=\'\';" />';
    		$form .=	'					<input type="submit" id="searchsubmit" value="go" class="icon-search"/>';
    		$form .=	'				</form>';
    		$form .=	'			</div>';
    
    		return $form;
    	}
    }
    
    // Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
    add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
    if ( ! function_exists( 'woocommerce_header_add_to_cart_fragment' ) ) {
    	function woocommerce_header_add_to_cart_fragment( $fragments ) {
    		global $woocommerce;
    
    		ob_start();
    
    		?>
    		<span class="cart_details"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count,THEMENAME), $woocommerce->cart->cart_contents_count);?> <?php _e("Total of",THEMENAME);?> <?php echo $woocommerce->cart->get_cart_total(); ?> <a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart',THEMENAME); ?>" class="checkout"><?php _e("Checkout",THEMENAME);?> <span class="icon-chevron-right"></span></a></span>
    		<?php
    
    		$fragments['span.cart_details'] = ob_get_clean();
    
    		return $fragments;
    
    	}
    }

    And the results page uses a blog template page to populate its results. I changed this code to use the_excerpt() but it still is not working

    <?php
    								if ( preg_match('/<!--more(.*?)?-->/', $post->post_content) ) {
    									echo $image;
    									the_excerpt('');
    								}
    								else {
    									echo $image;
    									the_excerpt();
    								}
    							?>

    Thoughts?

    Thank you again!

    Thank you!

    @cedric.charles

    Hi! I’m having the same issue you were having. Could you please explain to me how you ended up resolving it? Thanks so much!

    Cheers!
    Gabrielle

    Any word on this working with pages anytime soon? I’ve been looking all over for something like this but for with pages. Thanks!

Viewing 8 replies - 16 through 23 (of 23 total)