Title: Adding functionality to CG-SameCat
Last modified: August 18, 2016

---

# Adding functionality to CG-SameCat

 *  [themandril](https://wordpress.org/support/users/themandril/)
 * (@themandril)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/)
 * The CG-SameCat plugin is awesome and full of possibilities. Check out a sample
   page for my problem: [http://leftcoastlifestyle.com/blog/fashion/ya-ya-wheat-canvas-jacket/](http://leftcoastlifestyle.com/blog/fashion/ya-ya-wheat-canvas-jacket/)
 * I have created this code in my single post page:
 * ‘<?php
    if (function_exists(‘list_posts_of_cat’)) foreach((get_the_category())
   as $cat) { { $catp = list_posts_of_cat(get_the_category(), 10, 0, $post->ID);
   if ($catp) { echo “<div>”; _e(“Recent Finds in “);_e($cat->cat_name . ”);_e(“:”);
   _e($catp); echo “</div>”; } } } ?>’
 * And as you can see, it creates two lists, one for each category, but I’m not 
   smart enough to figure out how to either modify that chunk of code or the plugin
   code to make it create a list relevant to each category, currently it lists the
   same related items from the first category under each category heading.
 * I am sure this would be of use to a lot of people. Thanks for any ideas guys…

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309341)
 * Modify the innards to something like:
    ` if (function_exists('list_posts_of_cat'))
   foreach((get_the_category()) as $cat) { $catp = list_posts_of_cat($cat, 10, 0,
   $post->ID); if ($catp) { echo "<div>"; _e("Recent Finds in ");_e($cat->cat_name.'');
   _e(":"); _e($catp); echo "</div>"; } }
 * I think that’ll do what you want, though I’m doing this off the top of my head.
   😉
 * -d
    [CHAITGEAR](https://wordpress.org/www.chait.net/index.php?output_format=md)
 *  Thread Starter [themandril](https://wordpress.org/support/users/themandril/)
 * (@themandril)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309344)
 * Wow, I didn’t expect the man himself to respond! I tried that and variations 
   on it and it either returned no matching posts at all or broke it completely.
   Any other ideas?
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309708)
 * As I said, that was off the top of my head. I’d have to dig into the code, which
   isn’t going to happen immediately. If you haven’t heard back from me by the weekend,
   feel free to ping me at my site.
 * -d
 *  Thread Starter [themandril](https://wordpress.org/support/users/themandril/)
 * (@themandril)
 * [20 years, 3 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309804)
 * Any luck David? I checked out your site – very nice!
 *  Thread Starter [themandril](https://wordpress.org/support/users/themandril/)
 * (@themandril)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309899)
 * Bump. I tried working with it some more, no success. Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding functionality to CG-SameCat’ is closed to new replies.

 * 5 replies
 * 2 participants
 * Last reply from: [themandril](https://wordpress.org/support/users/themandril/)
 * Last activity: [20 years, 2 months ago](https://wordpress.org/support/topic/adding-functionality-to-cg-samecat/#post-309899)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
