Display only Child Categories on Single-listing

Discussion in 'GeoCraft WordPress Theme' started by tasburyjr, Aug 19, 2013.

  1. tasburyjr

    tasburyjr Member

    Joined:
    Jul 20, 2013
    Messages:
    44
    Likes Received:
    4
    How would I am it so on the front end of the single-listing.php that it only shows child categories?

    Thanks for help.
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Hello,

    Go to Appearance > Menus

    Create a custom menu and only add those listing categories that you want to show in the sidebar.

    Now, go to Appearance > Widgets

    Drag Custom Menu widgets and drop it in the Listing widget area and select your custom menu from select menu option of custom menu widget.
     
  3. tasburyjr

    tasburyjr Member

    Joined:
    Jul 20, 2013
    Messages:
    44
    Likes Received:
    4
    I want to only display child categories in the custom field section. Your solution is for the sidebar.

    Is there someway to only display child categories in the custom field section?

    On single-listing.php - this is the code that pulles the categories I am referring to.
    Goal: only show child categories
    Code:
     <?php
                                if ($p_categories):
                                    ?>
                                    <tr>
                                        <td class="label category"><?php echo S_CATEGORY; ?></td>
                                        <td><?php echo $p_categories; ?></td>
                                    </tr>
                                <?php endif; ?>
     
  4. tasburyjr

    tasburyjr Member

    Joined:
    Jul 20, 2013
    Messages:
    44
    Likes Received:
    4
    Any ideas on this?
     
  5. tasburyjr

    tasburyjr Member

    Joined:
    Jul 20, 2013
    Messages:
    44
    Likes Received:
    4
    Please help =)
     
  6. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello,

    Sorry for the delay.
    We are looking to it and will reply you as soon as possible.
     
  7. Nitesh

    Nitesh Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    5,165
    Likes Received:
    160
    Hello again,

    Open "single-listing.php" file and add code given below as shown in the image.

    Code:
    <?php
                                        foreach(get_the_terms($post->ID, 'listcat') as $cat) {  if($cat->parent) :     
                                            $term_link = get_term_link($cat->slug, 'listcat');
                                          echo "<a href='{$term_link}'>".$cat->name . "</a>".','; 
                                            endif; } ?>
    catcode.png
     

Share This Page