WordPress.org

Ready to get started?Download WordPress

Forums

related posts question (11 posts)

  1. Jinsan
    Member
    Posted 9 years ago #

    I've tried two different plugin, but perhaps I don't understand how it works. What I want is for the related posts plugin to display say, 5 random or previous entries from the category of the current post. So if the current entry is from WordPress category, then the related entries will be from the WordPress category be it random or in order, excluding the current entry.

    Here's my site: http://sekhu.net/wp/

    The entries should display in the bottom right hand side but I haven't got this to work quite yet. It's obviously trying and working, but not the way I need it to.

    Please advise.

    Thanks in advance

  2. Lorelle
    Member
    Posted 9 years ago #

    I use the following with the Related Posts Plugin:

    <ul>
    <li id="related"><?php _e('Related Articles'); ?>
    <ul><?php related_posts(10, 10, '<li>', '</li>', '', '', false, false); ?></ul></li>.......

    Which gives me 10 random posts related to the keywords and titles of the post.

  3. Jinsan
    Member
    Posted 9 years ago #

    So do you have to enter the keyword yourself? I have a large amount of posts, and I don't particuarly like the idea of going through each one to enter a keyword. Is it intelligent enough to read the current category and then say right it's in category x so let's pick out some random entries?

    I'll try your code in the meantime Lorelle. Cheers

  4. davidchait
    Member
    Posted 9 years ago #

    CG-SameCat in my CG-PowerPack was designed to show posts from the same category as the current post -- it was one of the 'original related posts' hacks. It just bases off the wp-cat, no other fields, no freetext searches, etc.

    -d

  5. Jinsan
    Member
    Posted 9 years ago #

    Sounds good David, and where does one locate your plugins. have to say that's the only reason I've never searched for your plugins, I never exactly knew where to get them from :)

  6. davidchait
    Member
    Posted 9 years ago #

    CG-PowerPack is at http://www.chait.net/index.php?p=238

    Usage is something like this after the post:

    <?php
    if (function_exists('list_posts_of_cat'))
    {
    $catp = list_posts_of_cat(get_the_category(), 3, 0, $post->ID);
    if ($catp)
    {
    echo "<div>";
    _e("Similar Posts:");
    _e($catp);
    echo "</div>";
    }
    }
    ?>

    -d

  7. jbbrwcky
    Member
    Posted 8 years ago #

    Hi david, tried your CG-samepost, kept giving me errors (using 1.5.1.3 WP).

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND post_date <= '2005-07-22 21:50:44' ORDER BY post_stat]
    SELECT DISTINCT ID, post_title, post_name, post_status, post_date FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND (category_id = 0) AND (post_status = 'publish' || post_status = 'sticky') AND ID != AND post_date <= '2005-07-22 21:50:44' ORDER BY post_status DESC, post_date DESC LIMIT 3

  8. Beel
    Member
    Posted 8 years ago #

    Are you sure you set it up correctly, I just activated the samecat plugin, copied the code above just after the_content() and it ran fine from the get-go.

  9. jbbrwcky
    Member
    Posted 8 years ago #

    Yeah, although I did put it in the sidebar (but it IS only activated when is_single() is checked). Would that have an effect?

  10. Beel
    Member
    Posted 8 years ago #

    No it shouldn't, the cause escapes me... I tested the code in my sidebar and added "&& is_single()". It worked fine. David may have some suggestions.

  11. davidchait
    Member
    Posted 8 years ago #

    jbbr - I assume that's with a recent CG-PowerPack version of CG-SameCat that you are seeing the issue? I had at some point fixed an issue with compatability with .1.2 or .1.3 where they changed the category functions to return objects instead of arrays (or something like that).

    If you're having issues with latest&latest, lemme know, and I'll try to take a look this week.

    -d

Topic Closed

This topic has been closed to new replies.

About this Topic