Home Forums WoodMart support forum Woodmart Ajax Search

Woodmart Ajax Search

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #271850

    sergiocosta
    Participant

    Hello,

    I created a new field using Advanced Custom fields, Now i’m trying to add on your function like that:

    if ( ! function_exists( ‘woodmart_get_post_suggestions’ ) ) {
    function woodmart_get_post_suggestions() {
    $query_args = array(
    ‘posts_per_page’ => 5,
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘post’,
    ‘no_found_rows’ => 1,
    );

    if ( ! empty( $_REQUEST[‘query’] ) ) {
    $query_args[‘s’] = sanitize_text_field( $_REQUEST[‘query’] );
    }

    if ( ! empty( $_REQUEST[‘number’] ) ) {
    $query_args[‘posts_per_page’] = (int) $_REQUEST[‘number’];
    }

    $results = new WP_Query( $query_args );
    $suggestions = array();

    if ( $results->have_posts() ) {

    $suggestions[] = array(
    ‘value’ => ”,
    ‘divider’ => esc_html__( ‘Results from blog’, ‘woodmart’ ),
    );

    while ( $results->have_posts() ) {
    $results->the_post();

    $suggestions[] = array(
    ‘value’ => html_entity_decode( get_the_title() ),
    ‘permalink’ => get_the_permalink(),
    ‘thumbnail’ => get_the_post_thumbnail( null, ‘medium’, ” ),
    ‘award’ => get_field(‘imagem_da_medalha’)
    );
    }

    wp_reset_postdata();
    }

    return $suggestions;
    }
    }

    I put on array this code: “‘award’ => get_field(‘imagem_da_medalha’)”. When i checked on Network Tab from Inspect Element, it doesn’t appear my new field.

    Anyway, i think this code is not making override. I tried to comment the while loop and the results continue to show.

    Check my attachment.
    Thanks.

    Attachments:
    You must be logged in to view attached files.
    #271855

    Artem Temos
    Keymaster

    Hello,

    It is hard to say why that value doesn’t appear there. Maybe you have done something wrong. Anyway, it requires additional investigation and code customization to check and fix this problem. Sorry, but it is out of our theme support scope.

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)