I'd like to return entries from a specific channel, but what i'd like to do is ONLY show entries from a child category first, but if there are none, then show entries from the child's parent category.
Is this possible?
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityI'd like to return entries from a specific channel, but what i'd like to do is ONLY show entries from a child category first, but if there are none, then show entries from the child's parent category.
Is this possible?
Put your loop on a embed and call it at this way:
{exp:channel:entries channel="news" limit="1" category="X"}
{if no_results}
{exp:query
sql="SELECT parent_id
FROM exp_categories
WHERE cat_id = X"
}
{embed="pages/.category_loop" cat_id="{parent_id}"}
{/exp:query}
{/if}
{embed="pages/.category_loop" cat_id="X"}
{/exp:channel:entries}