Scenario: When viewing a single entry, you would like to display the most recent entries on the side, excluding the currently viewed entry. By default, ExpressionEngine doesn't have a special function or parameter for it. However, there's a very simple way to add this feature; by creating a global variable and using it as a weblog parameter value.
We start by creating a new global variable and assigning it to the template we use to render our single entries.
{assign_variable:current_entry="{segment_3}"}
What we've done: we have created a new global variable with the name of current_entry and assigned it the value of {segment_3}, the third segment of the URL.
An Example: mysite.com/index.php/blog/single/my-entry-title
In this example, the entry title is the third segment of the URL. index.php does not count as a segment. If you've never worked with ExpressionEngine's URL segments before, you can find all information on how to use them in the EE docs.
In our single entries template we insert our code somewhere at the top, e.g. below our other assigned global variables.
{assign_variable:my_template_group="blog"}{assign_variable:my_weblog="blog"}"}{assign_variable:current_entry="{segment_3}"}
Now we can apply the newly created global variable to use as a parameter value in our weblog:entries tag.
The Logic
We have stored the entry title in {current_entry} in order to use this global variable in our weblog:entries tag as a parameter value. Next, we'll tell our function to exclude the entry title from our recent entries in our single entries template.
<ul class="recent-entries">{exp:weblog:entries weblog="{my_weblog}" dynamic="off" url_title="not {current_entry}"}<li><a href="/blog/single/{url_title}" title="read more on {title}">{title}</a></li>{/exp:weblog:entries}</ul>
It is important to have dynamic="off" in our weblog: entries tag.
In this example, we've added the url_title parameter and assigned it the value of {current_entry}. Additionally, we have prepended the value "not", which translates to the following: if we view a single entry, do NOT include the current URL title.
That's it. We could also separate this piece of code from our template and then include it via embeds. However, I prefer to not use too many embeds to ensure that not too many queries are used that might effect speed/performance.


Sean Gaffney writes on Fri Oct 8, 2010
So. Stinkin. Smart. I was completely unaware that “not” worked in the url_title. Thanks!