Forums Forums Search & Filter Pro Search by Post Title

Tagged: , ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #227292

    Hi there,

    I haven’t managed to find a solution in the forums. It should be fairly simple to do.

    I want to have a drop-down search field that lists all post titles from a specific custom post type.

    I have added an ACF field which stores the post title in each CPT and then I used the Search & Filter Post Meta field to create the field I need. However, the options Search & Filter gives are limited to either a boolean, a range, or a date. It does not give the option to simply list all posts titles.

    I see the ACF post title meta field in the Search Options when I build the search form but I cannot make it list the post titles.

    Am I missing something or is this not possible?

    Thanks

    Trevor
    #227343
    This reply has been marked as private.
    Anonymous
    #227362
    This reply has been marked as private.
    Trevor
    #227373
    This reply has been marked as private.
    Anonymous
    #227393
    This reply has been marked as private.
    Anonymous
    #227395

    In case it helps, the way the ACF field populates the Title is with a shortcode I created in functions.php:

    function mcl_get_title(){
        global $wp_query;
    
        return get_the_title($wp_query->post->ID);
    }
    add_shortcode('postTitle', 'mcl_get_title');

    So I have added the shortcode [postTitle] as default value in the field and I am expecting it to store the title as meta. It works on the front end. When I add the shortcode in a post it renders the post title.

    Eventually once everything works I will hide the ACF metabox (seamless) so that the cient doesn’t mess up anything.

    Trevor
    #227403

    Ah. That will be why it isn’t working. Instead, you need to have code in the functions.php based on the WordPress save_post() function that copies the title into that post meta field.

    The search looks for what you want:

    https://www.google.com/search?q=functions.php+save_post+copy+post+title+to+custom+field+site:wordpress.stackexchange.com

    But, the answers show how to copy the opposite way, but the logic can be reversed.

    Anonymous
    #227467

    That was the problem you were right. It’s all fixed now, you can mark this as resolved.

    Being able to do this with the click of a button would be a great feature for this plugin. A search by title feature.

    Thanks a lot for your help.

    Trevor
    #227473

    I believe it will be possible in V3. Thanks for letting me know. I will close this thread for now.

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