WP Manifestindependent plugin directory
manifest / content / wpusimilar

WPU Similar

★ 2stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/wordpressutilities/wpusimilar/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Retrieve Similar Posts

<?php
global $WPUSimilar;
if (isset($WPUSimilar) && is_object($WPUSimilar)) {
    $similar_post_ids = $WPUSimilar->get_similar(get_the_ID(), 'post', 'category', array(
        /* Return only post ids */
        'return_ids' => true,
        /* Return only top 3 (and return keys only) */
        'max_number' => 3,
        /* Complete with latest posts if not enough similar posts */
        'complete_with_latest' => true,
        /* Adds a 3 points boost to posts by same author */
        'same_author_boost' => 3
    ));
    echo "<pre>";
    var_dump($similar);
    echo '</pre>';
}
?>