Because of the URL schema on a site I'm working on I'm using {segment_x_category_id} (via Low Seg2Cat - http://gotolow.com/addons/low-seg2cat) to grab the category ID and pass it to a channel entries loop.

The problem I have is that there are a couple of specific categories which I never want to be navigable using this method. Usually I would exclude them specifically using category="not 1|2|3" but when I also need to pass in the category I want to display that's not going to work... any ideas?

3 Answers 3


@derek's answer is good, except that it will match other categories containing the numbers, like 18.

So, let's improve it using the contains and the concatenation operators, instead of a regex.:

{if '/32/15/8/' *= '/'.segment_x_category_id.'/'}

I'm using / as delimiter, but it could be some different character.


If you're running 2.9, you could use a regular expression conditional to send the visitor to a 404 when trying to browse those categories:

{if segment_x_category_id ~ "/32|15|8/"}

Nathan, you can also check GWcode Categories which gives you more flexibility dealing with categories.


{exp:gwcode_categories channel="abcd" cat_id="{segment_3_category_id}" depth="1|2" style="linear" excl_cat_id="1|3" limit="9" parse="inward"} {/exp:gwcode_categories}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.