WordPress.org

Ready to get started?Download WordPress

Forums

Adding functionality to CG-SameCat (6 posts)

  1. themandril
    Member
    Posted 8 years ago #

    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/

    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...

  2. davidchait
    Member
    Posted 8 years ago #

    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

  3. themandril
    Member
    Posted 8 years ago #

    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?

  4. davidchait
    Member
    Posted 8 years ago #

    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

  5. themandril
    Member
    Posted 8 years ago #

    Any luck David? I checked out your site - very nice!

  6. themandril
    Member
    Posted 8 years ago #

    Bump. I tried working with it some more, no success. Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic