I'm having some problems trying to format an If/Then condition in a Wordpress widget. In this case I want to say, "display all the recent posts titles in the sidebar, except for post ID 122. I'm not even sure exactly what should be the if/then condition should be, then there are other if/then statement already in the code, so I'm just confused as to where it should go.
Here's the ORIGINAL code found in the 'widget.php' file, where all the conditions of the sidebar widgets are stored:
$r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' =>true,
'post_status' => 'publish', 'ignore_sticky_posts' => true));
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
<ul>
<?php while ($r->have_posts()) : $r->the_post();?>
<li>
<a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a>
</li>
<?php endwhile; ?>
</ul>