Query posts using dropdown menu of custom fields
-
I have created this category archive which contains a table of 100 posts. The table contains 3 custom fields (Gender,Continent,Sector) and there is also a fourth (‘Overall’ with the only value ‘All’) which is not inside the table and their values for each post are inside the table cells of every entry/post. I have placed above the table four select tags (the four drop down menus) which I would like to filter the posts depending on which option of a certain select tag is chosen. To be more specific when a user choses for example select tag ‘Continent’ and option ‘Europe’ I would to query all posts with custom field value ‘Europe’. Is it possible to do that by using an if statement and how exactly would I syntax that? The select tags are the following:
For custom field Overall
<select> <option value="all">All</option> </select>
For custom field Gender
<select> <option value="gender">Select Gender</option> <option value="male" >Male</option> <option value="female">Female</option> </select
>
For custom field Continent
<select> <option value="continent">Select Continent</option> <option value="europe">Europe</option> <option value="america">America</option> <option value="africa">Africa</option> <option value="asia">Asia</option></select>
For custom field Sector
<select> <option value="sector">Select Sector</option> <option value="retail">FMCG/Retail</option> <option value="various">Various</option> <option value="finance">Finance</option> <option value="se">SE</option> <option value="energy">Energy</option> <option value="education">Education</option> <option value="fb">F&B</option> <option value="environment">Environment </option> <option value="telco">Tech/telco </option> <option value="fashion">Fashion </option> <option value="media">Media </option> <option value="construction">Construction </option> <option value="health">Health </option> <option value="tech">Tech </option> <option value="industry">Industry </option> </select>
- The topic ‘Query posts using dropdown menu of custom fields’ is closed to new replies.