• Resolved nibetanco

    (@nibetanco)


    Hi Steven, the Directory block filters the employees by lastname. I wanted to know if there is a way to filter them by name instead. Thank you

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Steven

    (@shazahm1hotmailcom)

    Sorry, no, there is no way to filter by the first name field. If you are not using the title, department, or organization fields, you could put the first name in one of those fields and use that for the filter. When displaying the directory, you could hide the display of the field you used.

    I hope this helps, please let me know.

    Thread Starter nibetanco

    (@nibetanco)

    No, I can’t ?? I actually use those fields too.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Hmmm… the only other option I can think of is using the Custom Metadata field and a meta query in the Advanced Options block settings field.

    You would add a new custom metadata field with the Key set to “name” and the Value set to the first name. Then use Example 1 from the docs, changing the key and value accordingly.

    I’ve never tested such a use case with the Directory Block, but, it should work.

    Thread Starter nibetanco

    (@nibetanco)

    I can’t find that Custom Metadata Fields option

    Plugin Author Steven

    (@shazahm1hotmailcom)

    When adding and editing an entry in the admin, click the Screen Options tab in the upper right. Enable the Custom Metadata Field. Now it should display near the bottom of the other entry fields.

    I hope this helps!

    Thread Starter nibetanco

    (@nibetanco)

    Thank you, I can see it now. But then I have another question. Do I have to do this for each employee then?

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Yes, sorry, that is the only solution I can think of for your use case. Before investing too much time, I would do just a few entries and ensure the desired results.

    Thread Starter nibetanco

    (@nibetanco)

    Where do I use those shortcodes?

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Since you are using the Directory Block, you add the meta_query to the Advanced Options block settings field.

    Thread Starter nibetanco

    (@nibetanco)

    Sorry, I don’t think I’m doing this right. So I updated an employee with a custom field name, and as a value I’m not sure if I should put the actual first name or just ‘first name’. And then in the directory block if I use the meta_query
    [connections meta_query='{“meta_key”:”color”,”meta_value”:”red”}’]
    instead of color: name
    but instead of red what should I write?

    Plugin Author Steven

    (@shazahm1hotmailcom)

    In the Custom Metadata field, click the “Enter New” link. The dropdown above will change to a text field. Enter “first_name”. In the “Value” field, enter the actual first name of the entry—for example, “John”. Save the change.

    In the Advanced Options field entry the meta query, not the shortcode. Example: meta_query='{"meta_key":"first_name","meta_value":"John"}'

    If that works, the result should be a directory with “John” as a result.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Directory block search by lastname’ is closed to new replies.