Can I filter search results by using the segment in ExpressionEngine?

expressionengine, search

Solution

Try this:

{exp:channel:entries 
    channel="specialist"
    dynamic="no"
    search:sp_specialty="={segment_2}"
}
    {if count == '1'}
        {if total_results == '1'}
            OUR SPECIALIST
        {if:else}
            OUR SPECIALISTS
        {/if}
    {/if}
{/exp:channel:entries}

- You want to use `total_results` not `total_entries`.

- Checking for 1 or fewer results is redundant as the channel entries tag will output nothing if there's no results (unless you use an `{if no_results}` tag pair).

Problem

I'm trying to get a word to read either singular or plural in expressionengine based on the amount of entries with a certain variable, but not having any luck. Here's what it is currently: ``` exp:channel:entries channel="specialist" dynamic="no" search:sp_specialty="={segment_2}" } {if total_entries <= 1 } OUR SPECIALIST {if:else} OUR SPECIALISTS {/if} {/exp:channel:entries} ``` Can I match a search using the segment value? Right now it's not working. Easier way of doing this?

Original source