Forums › Forums › Search & Filter Pro › Search by Post Title
Tagged: acf, post titles, V3
- This topic has 8 replies, 2 voices, and was last updated 5 years, 1 month ago by Trevor.
-
Anonymous(Private) November 21, 2019 at 11:18 pm #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
Anonymous(Private) November 22, 2019 at 3:22 pm #227395In 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(Private) November 22, 2019 at 3:39 pm #227403Ah. 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:
But, the answers show how to copy the opposite way, but the logic can be reversed.
-
AuthorPosts