• I’m wondering if there isn’t a clever way to add the UTW function ShowRelatedPostsForCurrentPost() to my feeds?

    I’ve seen this article which sparked the idea. However, I wish to use the UTW related posts function and I hope to avoid core file modifying.

    Anyone done this — or something like it — with a plugin? Any pointers or thoughts?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Chris_K

    (@handysolo)

    The plus side: I can build a plugin. I can even make it work as far as modifying content goes.

    The negative side: I (apparently) can’t just stuff the output from ShowRelatedPostsForCurrentPost() into a variable to add to the end of a feed.

    But I’m not a php ninja either. Is there a way to do that?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I’m not entirely sure what you’re trying to do, exactly. If you’re wanting to add that data into the_content as a filter for the case of feeds, then yes, I see your problem. ShowRelatedPostsForCurrentPost() actually echoes, where you need it returned instead.

    This is probably not the cleanest way to do it, but it might work:

    function UTW_GetRelatedPostsForCurrentPost($formattype, $format="", $limit = 0) {
    global $utw, $post;
    $format = $utw->GetFormat($formattype, $format);
    return $utw->FormatPosts($utw->GetRelatedPosts($utw->GetTagsForPost($post->ID), $limit), $format);
    }

    Thread Starter Chris_K

    (@handysolo)

    If you’re wanting to add that data into the_content as a filter for the case of feeds[…]

    Exactly.

    Not completely sure I follow your example, but I’ll go play with it for a bit and see where I end up.

    Right now I just have:

    function st_addRelatedtoFeed ($content) {
    	if ( ! is_feed() ) return $content;
    
    	$stutw = UTW_ShowRelatedPostsForCurrentPost("posthtmllist","",6);
    	$content = $content.$stutw;
       return ($content);
    }

    And you can spot pretty easily where it goes goofy. ??

    Thanks!

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Try this:

    function UTW_GetRelatedPostsForCurrentPost($formattype, $format="", $limit = 0) {
    global $utw, $post;
    $format = $utw->GetFormat($formattype, $format);
    return $utw->FormatPosts($utw->GetRelatedPosts($utw->GetTagsForPost($post->ID), $limit), $format);
    }
    function st_addRelatedtoFeed ($content) {
    	if ( ! is_feed() ) return $content;
    	$stutw = UTW_GetRelatedPostsForCurrentPost("posthtmllist","",6);
    	$content = $content.$stutw;
       return ($content);
    }
    Thread Starter Chris_K

    (@handysolo)

    You didn’t let me go play yet!

    I’m glad to see that’s about where I was headed though — and a quick test shows it is definitely on the right track.

    Many thanks!

    Thread Starter Chris_K

    (@handysolo)

    Thanks for your help Otto42!

    Plugin Released.

    I tried this – turned out to be pretty cool. Great idea, Handy.

    p.s. “Moderator+” ?
    Something wrong with “Supreme Ruler”?

    Thread Starter Chris_K

    (@handysolo)

    Glad you liked it.

    (Moderator++ seemed overly geeky.)

    I’ll have to try this out – great idea.

    (will others get a minus? ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘UTW – ShowRelatedPostsForCurrentPost() in the Feed?’ is closed to new replies.