Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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.

    #134282

    Hi,

    Edit functions-enfold.php, remove everything then replace it with this code: http://pastebin.com/i8tF4BsH

    Regards,

    Ismael

    #134283

    Is not working, now there is not appearing anything :S

    http://img209.imageshack.us/img209/1899/877.png

    #134284

    In 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.

    #134285

    I 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 .= "";

    }

    }

    #134286

    Hi,

    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

    #134287

    Argh! 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 ;)

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Ajax Search’ is closed to new replies.