Topic: Related news

Is there any way to add 5 related posts within full news page?
It's very important feature for any kind of cms script.

PHP codes will be appreciated.
Please help me to add this feature in my site that I want to run via cutenews.

2 (edited by 2015-04-22 12:53:47)

Re: Related news

Cutenews doesn't provide an opportunity to do Related Posts, but the following code might be helpful.

Based of this code, $ number of news will shown, but an important point is that the basis of the filter is tags. It means that posts will be shown only in accordance with the tags present in the post which is opened as Full News and with the tags present in active news. Each time a random tag will be chosen from the main news and searched.

Here's the code:

// Your code there

// Related Posts by tags
$GET = $_GET;

// Extended code for related posts
if (isset($_GET['id']) && $_GET['id']) {

    // Include required LIB!
    require_once 'cn_api.php';

    // Get current entry
    $info = cn_api_get_entry($_GET['id']);

    // Number of related posts
    $number = 5;

    // Show if TAG is presents
    if ($info['tg']) {

        $_tags = explode(',', $info['tg']);

        // Get RANDOM tag for search
        $_GET['tag'] = $_tags[mt_rand(0, count($_tags)-1)];


        // List post

$_GET = $GET;
Best regards,
CN Support team

Re: Related news

Great, it works

Re: Related news

Please give me a clue how to exclude the main news of this list