Support

Account

Forum Replies Created

  • Finally got this working and stable. A mixture of sources.
    Had a few issues with the fact I was creating an ajax search for a front end form.

    And them wanted to search more private fields in the admin using is_search && is_admin. The below is just for the ajax search. Set $GLOBALS[‘fd_search_term’] when the form data is posted.

    
    function cf_search_join($join)
    {
        global $wpdb;
    
        if (!is_search()) {
            $join .= ' LEFT JOIN ' . $wpdb->postmeta . ' ON ' . $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
        }
    
        return $join;
    }
    add_filter('posts_join', __NAMESPACE__ . '\\cf_search_join');
     
    function cf_search_where($where)
    {
        global $wpdb;
    
        // do not use !is_admin() as ajax returns this as true for ajax you can use :   !isset($GLOBALS['current_screen']) && !is_customize_preview() 
        if (!is_search() && $GLOBALS['fd_search_term']) {
    
            $s = $GLOBALS['fd_search_term'];
            // i have global array for each field to include.
            // To include all fields remove ' " . $wpdb->postmeta . ".meta_key IN ($imploded_fields) AND '
            $imploded_fields = implode(',', $GLOBALS['added_meta_field_to_search_query']);
    
            $where = preg_replace("/\(\s*" . $wpdb->posts . ".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
                "(" . $wpdb->posts . ".post_title LIKE $1) OR (" . $wpdb->postmeta . ".meta_key IN ($imploded_fields) AND " . $wpdb->postmeta . ".meta_value LIKE $1)  ", $where);
        }
    
        return $where;
    }
    add_filter('posts_where', __NAMESPACE__ . '\\cf_search_where');
    
    function cf_search_distinct($where)
    {
        global $wpdb;
    
        if (!is_search()) {
            return "DISTINCT";
        }
    
        return $where;
    }
    add_filter('posts_distinct', __NAMESPACE__ . '\\cf_search_distinct');
    
  • Thanks for the input John.

    A search for a string that does not exist does not return results – as expected. Or am I missing something here?

    The term can be in the title OR content OR any custom field defined in meta_query.

    Are you saying WordPress forces an AND to it.

    WordPress forces
    post_title, post_content AND (custom_field_1 OR custom_field_2 …) ?

    But I want
    post_title, post_content OR (custom_field_1 OR custom_field_2 …) ?

    thanks, D.

  • thanks I’ve seen that solution but its 5 years old now.

    Is it possible to re-include (title OR content) with $query.set() somehow?

    And seems odd that the taxonomy works. And tax_query is in query_vars[] & query[] but meta_query is missing from query[]?

    query[][tax_query] => WP_Tax_Query Object
            (
                [queries] => Array
        ....
    query[][meta_query] => 
  • Afraid it doesn’t work for me either. All required APIS added (I think!)

    APIs and error

  • looking for same solution – did you get anywhere?

  • afraid not. We had a rethink on the general approach.

  • I’ve tried this with limited success.

    The function is firing but the fields aren’t changing? I can echo out the title and newer Metabox title but seems like the filter is coming in too late to affect the layout of the groups?

    Has anything changed with ACF Pro that could of affected this?

    And when I print_r($field_groups) I get the whole site’s fields and not just the ones for the post edit. Maybe this is normal?

  • any update on this or what permissions need to be set for saving json to work? Constantly having issues with ace json locally and on servers. Seems to work quite randomly

  • There’s no ‘but’ john. I”m not really sure what your point is. I don’t care about the details i’m just pointing out a possible improvement to this link field which i thought it already did.

    Simpler is better for everyone.

    I’ll write a function myself to insert local links with an ID so all of my links work indefinitely.

  • I understand John but it would be a handy upgrade to the field. I’ll now have 3 fields whereas i thought i could just have one.

  • Thanks john.

    Slugs will change dozens or even hundreds of times before a site is launched.

    Was trying to take advantage of the link label feature this field type has. This is used for external links too. Simpler for clients.

    Would be a smoother user journey and reduce the amount of fields if internal links could used the ID to keep links going to the intended page.

    best, Dan.

  • I have a similar issue. The maps load on the backend and front end using the correct API key.

    But I cannot search for an address.

    It says “This page can’t load Google Maps correctly.”

  • Hello – i’ve been using various tools to grab remote sql to import locally. My links are never imported and this has been going on for 4 or 5 months now.

    I’ve tried mysql exports, WP migrate and a few other methods but the links or their labels are never imported.

    I have no issues with other data at all

  • Annoyingly i’ve already deleted all my fields and check this useful thread a bit too late to read the clean on delete possibilities.

    I’ve got around 4,000 posts with a lot of dead meta.

    Couldn’t this be achieved with a bit of SQL? Trying to piece it together but not my strongest field!

    post_type=’acf-field’, post_excerpt seems to be the name of the field in this case ‘post_startdatetime’

    post_meta.meta_key is then like this
    post_startdatetime
    _post_startdatetime

    So if the post_type=’acf-field’ are deleted could we loop through the post_meta.meta_key, check if there’s a matching posts.post_excerpt and if not delete the post_meta entry?

    But there’s there’s an entry per post with a name like ‘field_534fe013d9a0d’ though we would still get 75% of unused post_meta.

  • Thanks Keith — i have read it several times but the menu items aren’t appearing in the ‘menu item’ menu. And if if i set a negative that should make it appear in all menu items it still doesn’t.

    Can you explain what this refers to?

    That’s precisely how it’s supposed to behave.

    Is the screenshot ‘correct’ ie menu items shouldn’t appear ? Or are you saying it should work?

  • option screenshot

  • did you manage to solve this? Seems you can select Menu Item in the location options but it only shows the menu names. Not the items.

  • is there a user friendly way to do this yet? ie via ACF plugin!?

  • how did you sort it?

  • A simple way to find what posts a certain post may of been related to via the post object or post id select fields.

    ie Post A has 5 posts related to it (Posts B to C) via a post object select field called this_posts_related_content.

    When on Post B’s single page is there a function that can list what posts Post B has been related too if any? So this function would somehow return Post A.

  • It makes sense but not exactly a smooth user journey.

    Its my clients who will have to do this and they aren’t so hot on WordPress / data input to begin with. I just think a message saying ‘no matches — CREATE NEW POST’ would make data inputting and relating content pretty foolproof and very quick.

    I love ACF and have a pro license. I just find its hits a wall sometimes and then we have to turn to another less reliable plugin or build it ourselves.

    I rely (and pay for) on great plugins like ACF to make these features easy to add. Even being able to add a submit button via the interface would be amazing. And backwards relating from a post that has been related to another via post object or post id…

  • this may be a quicker way –
    http://php.net/manual/en/function.ksort.php

    <?php
    $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
    ksort($fruits);
    foreach ($fruits as $key => $val) {
        echo "$key = $val\n";
    }
    ?>
  • thanks James but that is quite beyond me. I’ve bought ACF pro and really don’t understand out of all of the types, functions and options there isn’t a button option?

Viewing 25 posts - 1 through 25 (of 29 total)