We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Display Parent and Child Categories in entry

Development and Programming

Eastwood Design's avatar
Eastwood Design
605 posts
8 years ago
Eastwood Design's avatar Eastwood Design

I have a listing with entries that have wither parent selected and some with parent and children categories selected. In my list of entries (like a business Directory) I have state as parents and cities as children. I want to display the state and then the city in each entry.

The entries are all grouped by parent category first.

So like this:

STATE CATEGORY A HEADING - entry title, State City - entry title, State City - entry title, State City

STATE CATEGORY B HEADING - entry title, State City - entry title, State City - entry title, State City

But My code is outputting the following (no child categories, instead the parent is displayed twice)

STATE CATEGORY A HEADING - entry title, State State - entry title, State State - entry title, State State

STATE CATEGORY B HEADING - entry title, State State - entry title, State State - entry title, State State

{exp:channel:categories channel="database" parent_only="no" style="linear" show_empty="no" dynamic="off"}
<h1>{category_name}</h1>

{exp:channel:entries orderby="title" sort="asc" channel="database" category="{category_id}"}
<h3>{title}</h3>
<h5>{categories} <a href="http://{path=site/business_directory}">{category_name}</a> {/categories}</h5>
{/exp:channel:entries}
{/exp:channel:categories}
       
Eastwood Design's avatar
Eastwood Design
605 posts
8 years ago
Eastwood Design's avatar Eastwood Design

this was my solution {exp:gwcode_categories entry_id="{entry_id}” style=”linear” backspace=”0” depth=”1|2”}{cat_name}  {/exp:gwcode_categories}

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.