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)