-
AuthorPosts
-
August 9, 2013 at 5:49 pm #27519
I will like to change one thing in the ajax search. When the results are appearing, it appears the excerpt or the date for that entry. I will like to show the category which belongs to. I already find the place where to change (in functions-enfold.php) but when I try to retrieve the category, the only thing that appears is the string Array.
How I can fix it?
Thank you.
August 10, 2013 at 3:16 am #134282Hi,
Edit functions-enfold.php, remove everything then replace it with this code: http://pastebin.com/i8tF4BsH
Regards,
Ismael
August 10, 2013 at 6:46 am #134283Is not working, now there is not appearing anything :S
August 10, 2013 at 9:26 am #134284In functions-enfold.php replace
if(!empty($post->post_excerpt))
{
$excerpt = apply_filters( 'avf_ajax_search_excerpt', avia_backend_truncate($post->post_excerpt,70," ") );
}
else
{
$excerpt = apply_filters( 'avf_ajax_search_time_format', get_the_time(get_option('date_format'), $post->ID) );
}with
if(!empty($post->post_excerpt))
{
$excerpt = apply_filters( 'avf_ajax_search_excerpt', avia_backend_truncate($post->post_excerpt,70," ") );
}
else
{
$excerpt = apply_filters( 'avf_ajax_search_time_format', get_the_time(get_option('date_format'), $post->ID) );
}
$taxonomies = get_object_taxonomies(get_post_type($post->ID));
$cats = '';
$excluded_taxonomies = apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'));
if(!empty($taxonomies))
{
foreach($taxonomies as $taxonomy)
{
if(!in_array($taxonomy, $excluded_taxonomies))
{
$terms = get_the_terms( $post->ID, $taxonomy );
if(!empty($terms))
{
foreach($terms as $term)
{
$cats .= $term->name .' ';
}
}
}
}
}and
$output .= $excerpt;
$output .= " </span>";
$output .= "</span>";with
$output .= $excerpt;
$output .= " </span>";
$output .= "</span>";
$output .= __('Categories:','avia_framework') . ' ' .$cats;This will add a list of all categories to the search result. However it’s not possible to apply add links to the categories which point to the category archive pages because the search results are wrapped into an a href tag and you can’t create a link inside a link. On the other hand the layout will be messed up if you add the categories after the a href element.
August 10, 2013 at 12:33 pm #134285I don’t know why, but still not working :S
URL: http://www.lt-light.com/new
Code:
foreach($post_type as $post)
{
$image = get_the_post_thumbnail( $post->ID, 'thumbnail' );
$extra_class = $image ? "with_image" : "";
$post_type = $image ? "" : get_post_format($post->ID) != "" ? get_post_format($post->ID) : "standard";
$iconfont = $image ? "" : $avia_config[$post_type];
$excerpt = "";
if(!empty($post->post_excerpt))
{
$excerpt = apply_filters( 'avf_ajax_search_excerpt', avia_backend_truncate($post->post_excerpt,70," ") );
}
else
{
$excerpt = apply_filters( 'avf_ajax_search_time_format', get_the_time(get_option('date_format'), $post->ID) );
}
$taxonomies = get_object_taxonomies(get_post_type($post->ID));
$cats = '';
$excluded_taxonomies = apply_filters('avf_exclude_taxonomies', array('post_tag','post_format'));
if(!empty($taxonomies))
{
foreach($taxonomies as $taxonomy)
{
if(!in_array($taxonomy, $excluded_taxonomies))
{
$terms = get_the_terms( $post->ID, $taxonomy );
if(!empty($terms))
{
foreach($terms as $term)
{
$cats .= $term->name .' ';
}
}
}
}
}
$link = apply_filters('av_custom_url', get_permalink($post->ID), $post);
$output .= "";
$output .= "<span class='ajax_search_image'>";
$output .= $image.$iconfont;
$output .= "</span>";
$output .= "<span class='ajax_search_content'>";
$output .= " <span class='ajax_search_title'>";
$output .= get_the_title($post->ID);
$output .= " </span>";
$output .= " <span class='ajax_search_excerpt'>";
$output .= $excerpt;
$output .= " </span>";
$output .= "</span>";
$output .= __('Categories:','avia_framework') . ' ' .$cats;
$output .= "";
}
}
August 12, 2013 at 3:44 am #134286Hi,
The revision I gave you for the function-enfold.php works on my end. Please do it again, remove browser cache the reload the page.
Regards,
Ismael
August 12, 2013 at 6:18 am #134287Argh! Stupid me. I’m using a child-theme, and I forgot that the functions-enfold.php I have in my child theme, and I was changing everthing in the parent theme hahaha
Thank you, now it’s working perfectly ;)
-
AuthorPosts
- The topic ‘Ajax Search’ is closed to new replies.