• Resolved therealoc

    (@therealoc)


    I have a sidebar that i made that shows some recent posts and am using MySQL to select everything from the table that has a certain post parent.

    On thing that i am trying to do now is exclude the current page from the results. Does anyone know how to do that? Is there a certain place where an $except would go within the MySQL query or the foreach bit of php (e.g. foreach($pages as $page $exceept(8141)):)

Viewing 2 replies - 1 through 2 (of 2 total)
  • foreach($pages as $page $exceept(8141)):

    since thats your “code”, and not how a plugin would do this…

    the current page

    if whatever it is youre displaying post-wise isnt paged, you could use an offset.

    If it is a plugin youre using, it would help to know which one.

    Thread Starter therealoc

    (@therealoc)

    Have actually just found a way of doing it that is really easy so i though i would put it up for anyone who is interested. If you need to exclude something such as the ID of the current page from a MySQL statement then just add something like WHERE ID != $post->ID when selecting something something using MySQL. If you don’t know your MySQL != stands for not equal too (just in case). Hope this helps anyone else who had this same problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude current page from MySQL results’ is closed to new replies.