• I am creating my own theme and am trying to use the search form with this plugin. The search form itself works, but I can’t find any ACF fields.

    My search.php looks like this, am I missing something?

    <div>
    
    <?php
    $query = new WP_Query( array( 's' => get_search_query() ) );
    
    if ( $query->have_posts() ) {
           _e("<h2>Search Results for: ".get_query_var('s')."</h2>");
    
           while ( $query -> have_posts() ) {
              $query -> the_post(); ?>
               <li>
                 <a href="<?php the_permalink(); ?>">
                   <?php the_title(); ?>
                 </a>
               </li> <?php
            }
    
        } else { ?>
            <h2>Nothing Found</h2>
            <p>Sorry, but nothing matched your search criteria. Please try again with some different keywords.</p>
    <?php } ?>
    
    </div>
    • This topic was modified 6 years, 4 months ago by nifel.
    • This topic was modified 6 years, 4 months ago by nifel.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @nifel,

    Make this change in plugin code:
    https://gbiorczyk.pl/img/8jYkbzF.png

    Send me:
    1. SQL query displayed after change in code when you try to search for.
    2. Database dump (only table wp_posts and wp_postmeta tables). Please delete private data from it, if any.
    3. ID of post you want to find.
    4. List of used plugins.
    5. Version of ACF plugin and version of ACF: Better Search.

    Thread Starter nifel

    (@nifel)

    1. SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_postmeta AS a ON (a.post_id = wp_posts.ID) INNER JOIN wp_postmeta AS b ON ((b.meta_id = a.meta_id + @@auto_increment_increment) AND (b.post_id = wp_posts.ID)) WHERE 1=1 AND (((b.meta_value LIKE 'field_%') AND (a.meta_value LIKE '%bultsvets%')) OR ((wp_posts.post_title LIKE '%bultsvets%') OR (wp_posts.post_content LIKE '%bultsvets%') OR (wp_posts.post_excerpt LIKE '%bultsvets%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_title LIKE '{2aee8da4a47a6f9940c76b78b0fe1b0ef297476c7a1ed7ec4e3b0212199eb79a}bultsvets{2aee8da4a47a6f9940c76b78b0fe1b0ef297476c7a1ed7ec4e3b0212199eb79a}' DESC, wp_posts.post_date DESC LIMIT 0, 4

    2. https://we.tl/t-FK2X6UOqVj

    3. 194

    4/5.
    ACF: Better Search – Version 3.1.2
    Advanced Custom Fields PRO – Version 5.7.7
    BJ Lazy Load
    Contact Form 7
    Heroic Favicon Generator

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    194 is not a post, only an ACF field ID. In the database, phrase “Bultsvets” contains only one image – there is no such value in the ACF fields.

    Thread Starter nifel

    (@nifel)

    So how can I search for the text I put in that ACF field?

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    First, put this content. You gave me phrase “Bultsvets”, and you have no such phrase in any ACF field.

    Thread Starter nifel

    (@nifel)

    It is a repeater sub-field, is that the problem?

    As you can see in this screenshot I have the phrase “Bultsvets” inside that ACF field I sent you.

    https://i.imgur.com/816Dik3.jpg

    Thread Starter nifel

    (@nifel)

    Or maybe it’s because its in “option”?

    <?php the_sub_field('motstand_produkttitel', 'option'); ?>

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Look here:
    https://i.imgur.com/AGdnG6B.png

    Where do you have “Bultsvets”? This works for ACF fields for posts, not Options Pages.

    Thread Starter nifel

    (@nifel)

    Well, that explains it then.

    I have one acf_add_options_page with a redirect to all the rest of acf_add_options_sub_page basically. I did this because it looked better.

    So I guess there’s no way to get a search on them when they are option pages?

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    How do you want to search for a posts based on options? Options pages are global for website.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Cant find any fields’ is closed to new replies.