Trying to make custom fields clickable, to search for same values
-
Hi to all!
My intention is to build a private, non-public website where I plan to insert (as posts) places I would like to visit. Something like “extended” Bucket list. It’s open public right now because I need your help.I created couple categories, enter couple posts… And then I realized I’m gonna have some problems with “location”. Every post should have Address, City, State, Country (provinces, territories, regions… I’m gonna deal with it later) so I can list all posts with the same selected City/State/… So, they have to be “linkable”, “selectable” (don’t know what would be the correct term… please, bear with me…) so by selecting the value of the City, related to the place in the post, I want to list all places (posts) with that specific city. Very similar to Categories: e.g. if you select category “Movies” you’ll get a list of all posts with the category “Movies”.
First I thought to use Tags. It’s doable. It would work, but only if I use city, state and country tags, and no other tags. Otherwise it’s gonna be mess of mixed location tags and other tags. Also, I can’t control the tag sorting because they are sorted alphabetically… I abandoned this plan.
After doing some research I found ACF plugin. Installed, created a Group, added custom fields… Everything looks cool – until I realized I can’t see it on the front page. Ok, back to research.
I kinda solved the “problem” but it looks weird, doesn’t seems right to me. Using Appearance/Editor I added the following code into templet-parts -> post -> content.phpecho '<div style="font-size: .9em; margin-bottom: 25px; padding: 25px;">'; if (get_field('google_map')) { $google_map = get_field('google_map'); echo '<a href="'.$google_map.'">Google Map</a><br />'; } if (get_field('google_street_view')) { $gsv = get_field('google_street_view'); echo '<a href="'.$gsv.'">Google Street View</a><br />'; } if (get_field('facebook')) { $facebook = get_field('facebook'); echo '<a href="'.$facebook.'" rel="category tag">Facebook</a><br />'; } if (get_field('city')) { $city = get_field('city'); echo 'City: '.$city.'<br />'; } if (get_field('state')) { $state = get_field('state'); echo 'State: '.$state.'<br />'; } if (get_field('country')) { $country = get_field('country'); echo 'Country: '.$country.'<br />'; } echo '</div>';
I, actually, solved the issue just partially. It works fine for Google Map and Street View links, but not for city, state and country fields. I know there are several different options for field types in ACF but can’t figure out how to make them searchable, e.g. if I enter Iowa for the State field, and click on the State (value) link, to get the list of all posts that have value “Iowa” in custom field “States” (Somehow I have a feeling I’m confusing you more and more, right?)
So, how to do this? Or, if you would suggest different approach, please let me know.
Thanks for any help.
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘Trying to make custom fields clickable, to search for same values’ is closed to new replies.