Support

Account

Home Forums Front-end Issues Sort by dropdown value?

Solving

Sort by dropdown value?

  • Hi there,
    I am pretty new to WordPress and ACF, so please forgive me for stupid questions 😉
    I have created a custom post type “apprenticeship” and created with ACF some fields like title, duration, preferred school degree etc. Some of the fields like duration and preferred school degree are dropdowns with pre-defined value like “highschool”, “middle school”, “university” or “1 year”, “2 years” and so on.

    I would like to show now on the front-end a link “Apprenticeships with preferred school degree Highschool”, “Apprenticeships with preferred school degree Middle school” etc. When the user hits the button, there should be a list of all apprenticeships with the selected school degree. If the user chooses a specific apprenticeship he should see the detail page.

    I am not sure what wordpress template I have to use? category-apprenticeship.php or tag-apprenticeship.php (for the list of apprenticeships) and single-apprenticeship.php (for detail) and how to query those values. I am really appreciate any help!

    thanks,
    Marius

  • There is not template in WP that will show a list of posts based on an ACF field. For this you would need to create your own query and url to use. This is explained in the Dynamic $_GET parameters section of this page https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    Since you are new to WP I will make a suggestion. WP has a build in mechanism for doing what you want to. https://codex.wordpress.org/Function_Reference/register_taxonomy.

  • Thanks John! I looked into your links.
    Do I need to register a taxonomy for every “dropdown”-field I have in my ACF? In this case I need to fill out twice everything, correct? So for example I have to select “2 years” in the acf-dropdown and select “2 years” in my newly created taxonomy “duration”.

  • I’m not sure what you’re asking. I will tell you that custom taxonomies can be one of the most difficult things in WP for some. But if I understand, then yes. Each select field that you want to be able to list posts for would be a different custom taxonomy.

    I guess it would depend on how many of these sorting/filtering fields you want to have for these posts. If you’re going to end up with a lot of them then you might want to look into a search plugin to add to your site. https://facetwp.com/ is a fairly good one and there are others if you look. It really depends on how complicated it will be and what you want for the end result.

  • Hey John, you mentioned that you know some alternatives to FacetWP – would you mind listing a few?

  • I don’t know them specifically, when I want to use something quick I use FacetWP. When I have the time I build all the code required for the search myself, which is based on the first link I posted, the Dynamic $_GET parameters section of https://www.advancedcustomfields.com/resources/query-posts-custom-fields/. As far as I know there are no “free” plugins that will do searches based on ACF field types, or I should say, they will work on the “Basic” field types, but not on any of the more complicated ones.

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

The topic ‘Sort by dropdown value?’ is closed to new replies.