• Resolved Tedmanders

    (@tedmanders)


    I have a standard WordPress search.php page without modifications to the loop. I have ACF better search installed and checked the boxes for text, textarea and wysiwyg fields.
    When I search for a word that is in either of those fields, I get no results back. The search only seems to be working for standard Pages and Post post types.
    I have added ACF fields to my custom post type, which is registered with: register_post_type();

    Could you please help me fix the problem?

    I have ACF Pro installed (5.7.7) and ACF better search (3.1.2). My WordPress is version 4.9.8.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Tedmanders

    (@tedmanders)

    This is the SQL query of the search (I added the code you posted in other threads for functions/search.php)

    SELECT DISTINCT SQL_CALC_FOUND_ROWS abctrac_posts.* FROM abctrac_posts LEFT JOIN abctrac_term_relationships ON (abctrac_posts.ID = abctrac_term_relationships.object_id) INNER JOIN abctrac_postmeta AS a ON (a.post_id = abctrac_posts.ID) INNER JOIN abctrac_postmeta AS b ON ((b.meta_id = a.meta_id + @@auto_increment_increment) AND (b.post_id = abctrac_posts.ID)) INNER JOIN abctrac_posts AS c ON ((c.post_type = ‘acf-field’) AND ((c.post_content LIKE ‘%:”text”%’) OR (c.post_content LIKE ‘%:”textarea”%’) OR (c.post_content LIKE ‘%:”wysiwyg”%’))) WHERE 1=1 AND (
    abctrac_term_relationships.term_taxonomy_id IN (2)
    )AND (((c.post_name = b.meta_value) AND (a.meta_value LIKE ‘%volvo%’)) OR ((abctrac_posts.post_title LIKE ‘%volvo%’) OR (abctrac_posts.post_content LIKE ‘%volvo%’) OR (abctrac_posts.post_excerpt LIKE ‘%volvo%’))) AND abctrac_posts.post_type IN (‘post’, ‘page’, ‘attachment’, ‘artikelen’) AND (abctrac_posts.post_status = ‘publish’ OR abctrac_posts.post_status = ‘acf-disabled’) GROUP BY abctrac_posts.ID ORDER BY abctrac_posts.post_title LIKE ‘{b050309699cde54c19f3db5d799109dadcc74f4b57f8f0b694228cacbe41675e}volvo{b050309699cde54c19f3db5d799109dadcc74f4b57f8f0b694228cacbe41675e}’ DESC, abctrac_posts.post_date DESC LIMIT 0, 10

    • This reply was modified 6 years, 4 months ago by Tedmanders. Reason: spelling
    Thread Starter Tedmanders

    (@tedmanders)

    And the query result of:
    SELECT * FROM abctrac_postmeta WHERE post_id = 541

    View post on imgur.com

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @tedmanders,

    Can you give me slug of your post type?

    Thread Starter Tedmanders

    (@tedmanders)

    Hi @mateuszgbiorczyk,

    I don’t have slug defined in the register post type so I guess it defaults to the post type name ‘artikelen’ ?
    I do have the following rewrite defined to edit the url to display categories and children of categories:
    `’rewrite’ => array(
    ‘slug’ => ‘producten/%category%’, ‘with_front’ => true,
    ),’

    %category% get’s replaced later using a hook in my functions file. I’m not sure if it’s relevant to the problem, but maybe the url customizing has an effect on the search.

    Thank you for your help.

    • This reply was modified 6 years, 4 months ago by Tedmanders. Reason: spelling, clarity
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Do you search in category?

    (
    abctrac_term_relationships.term_taxonomy_id IN (2)
    )
    Thread Starter Tedmanders

    (@tedmanders)

    How do you mean?
    I search in the standard WordPress search form for a term in an ACF field.
    The post with the field can be in a (sub)category.

    For example I type ‘volvo’ in the form. Which is a name in the title field of a post.
    I wonder why this taxonomy id is added to the SQL..
    Do you know why this gets added to the query?

    Thread Starter Tedmanders

    (@tedmanders)

    Hi @mateuszgbiorczyk,

    I have checked term_taxonomy_id IN (2) in the database and it seems to be the currently selected language that is added by the plugin ‘Polylang’
    Each language seems to have it’s own term ID.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @tedmanders, can you check if version 3.0.1 was working correctly for you?

    Thread Starter Tedmanders

    (@tedmanders)

    Hi @mateuszgbiorczyk,

    I have installed version 3.0.1 and this one seems to be working. The search results now show my CPT content, so that’s great.
    The search query is takes quite long though, atleast 5 seconds. Are there any security risks by using the older version?

    Thank you for your help.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @tedmanders,

    Please make update to latest version (3.1.2) and change one line in /functions/search.php file:

    View post on imgur.com

    Did it help?

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Additionally please make this sql command in phpmyadmin:
    SHOW VARIABLES LIKE 'auto_inc%';

    and show me results.

    Thread Starter Tedmanders

    (@tedmanders)

    Hi @mateuszgbiorczyk,

    I have updated the plugin and modified the code. The search is working well now!

    Below a screenshot of the result from the sql command in phpmyadmin:

    View post on imgur.com

    Thank you so much for your help. I appreciate it!

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @tedmanders,

    I am happy to. Can I ask you to add a review for my plugin? I will be grateful for 5 stars.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘No results are found in ACF fields’ is closed to new replies.