Support » Plugin: YARPP - Yet Another Related Posts Plugin » Related posts with custom content type not showing

  • I have a custom content type called ‘product’. I have created this using the Custom Content Type Manager plugin. Its a normal post except that it has a couple of extra fields.

    I am trying to use this YARPP plugin to list related products based on title and body text however I am not getting anything. (I have 6 products all of which have ‘lorem ipsum’ text, which should definitely match and seem related).

    I have my own custom template, which just has the loop like this to display the related products in a grid.

    <?php if (have_posts()):?>
        <div id="related">
            <h2>Related Items</h2>
    
        <table id="related-items">
            <?php for ($i = 0; have_posts(); $i++) : the_post() ?>
            <?php if ($i % 4 == 0) echo '<tr valign="top">'; ?>
                <td width="25%"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail(array(160,160), $attr); ?><p><span class="item_desc"><?php the_title(); ?></span></p><span class="more"></span></a></td>
            <?php if ($i % 4 == 3) echo '</tr>'; ?>
            <?php endfor; ?>
            <?php if ($i % 4 != 3) echo '</tr>'; ?>
        </table>
    </div> <!-- #related -->
    <?php endif; ?>

    Then in the product page itself (single-product.php) I have this inside the normal loop:

    <?php related_posts(array(
            'template' => 'yarpp-template-productlist.php',
            'post_type' => array('product')
        )); ?>

    I don’t even get the Related Items heading, so have_posts() is returning false (but I know my template is being invoked, because when I put something out of the loop it appeared).

    I have also converted my table to MyISAM using ALTER TABLE wp_posts ENGINE = MyISAM; and set bodies, titles and categories to ‘Consider with extra weight’ and tried Match threshold 1 and 5, without any effect.

    Is there something else I need to enable for this to work?

    https://wordpress.org/plugins/yet-another-related-posts-plugin/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jbx

    (@jbx)

    So I suspected that the reason might be because I don’t have the yarpp_support property on my custom post type (I am creating it using the Custom Content Type Manager so I don’t have access to the properties). Even though I am explicitly passing it to the related_posts() function.

    I tried to comment out the yarpp_support check and made post_type_filter return true always. I then went to the YARPP settings page and appended &action=flush. But I still can’t get any related products 🙁

    Is there any way I can debug what’s going on?

    Plugin Author YARPP

    (@jeffparker)

    Are you seeing your custom post type listed in the “Display options” panel, next to Posts, Pages, and Media? If not, then the custom post type is most likely not being registered correctly to “play well” with YARPP.

    In cases like these, I suggest reaching out to the Custom Content Manager plugin and ask how best to integrate YARPP support.

    Thread Starter jbx

    (@jbx)

    Hi, Thanks for your reply.
    Yes since I disabled the yarpp_support check temporarily to try and figure out where the problem is coming from I can now see not only Posts, Pages and Media, but also Revisions, Navigation Menu Items, Contact Forms and Product. The latter is the one I want.

    I tried to use both related_posts() and related_entries() but none seem to give me any related items.

    Is there any other way I could understand what’s actually happening? It doesn’t seem to be coming from the yarpp_support flag now because I commented out and that function just returns true.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Related posts with custom content type not showing’ is closed to new replies.