• 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: https://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

Viewing 10 replies - 1 through 10 (of 10 total)
  • 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.

    Thread Starter jinsan

    (@jinsan)

    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

    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

    Thread Starter jinsan

    (@jinsan)

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

    CG-PowerPack is at https://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

    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

    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.

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

    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.

    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

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘related posts question’ is closed to new replies.