修改显示/隐藏以包含php

I am working with a show/hide script that works to show/hide text, but when I try to put some php (script to display recent posts [WordPress]) it doesn't work. Actually, the text still shows/hides, but the php displays always (below the action on the page).

I suspect it might have to do with using <span>s, which act weird in general, at least with this show/hide. If I try to put it inside a <p>, for example, it breaks the function.

Here is the code. Maybe someone can show me how to put php inside, or maybe I need a new starting point? The goal is just to display various things inside a basic light show/hide.

HTML:

<span class="span3">Hide</span>
<span class="span2">Show</span>
<p class="alert" >Some text inside the show/hide</p>

What I want to put inside the show/hide:

<div class="featured-articles">
<?php
    $args=array(
      'tag' => 'feature-left',
      'showposts'=>5,
      'caller_get_posts'=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Today';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
       <?php
      endwhile;
    } //if ($my_query)
  wp_reset_query();  // Restore global post data stomped by the_post().
?>
 </div>

CSS:

body {
  display: block;
}
.span3:focus ~ .alert {
  display: none;
}
.span2:focus ~ .alert {
  display: block;
}
.alert{display:none;}

(origin code author: Vector)

If I understood your question, this is what you are trying to do:

body {
  display: block;
}
.span3:focus ~ .alert {
  display: none;
}
.span2:focus ~ .alert {
  display: block;
}
.alert {
  display: none;
}
.span2,
.span3 {
  outline: none;
}
<span tabindex="0" class="span3">Hide</span>
<span tabindex="0" class="span2">Show</span>
<p class="alert">Some text inside the show/hide</p>

To insert php you should of course do something such as:

<p class="alert" ><?php echo 'Some text inside the show/hide'; ?></p>

And, of course, make sure that text which you are echoing has html entities properly encoded.

Edit:

After your additional explanation, your problem is layout structure, you can't put div inside of p. p tag can not contain block elements. Replace p with div and it should be OK:

<div class="alert">Your featured articles html here</div>
</div>