Question

what would be the best way to exclude the current post I am viewing from this recent posts query. Thank You!

<?php
            global $post;
            if (in_category('top-lists')) {
                $myposts2 = get_posts('numberposts=5&offset=0&category=7');
            }
            else if (in_category('playlists') || in_category('playlistall')) {
                $myposts2 = get_posts('numberposts=5&offset=0&category=6,37');
            }
            else if (in_category('news') || in_category('news')) {
                    $myposts2 = get_posts('numberposts=5&offset=0&category=95');
            }
            else {
                $myposts2 = get_posts('numberposts=5&offset=0&category=-6,-7,-37,-95,-177');
            }

            foreach($myposts2 as $post) :
            ?>

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top