how to do a wordpress link block?
does anyone have an idea on the css that would turn the following in to a linked block?
<div class="one_third">
<?php
//The Query
query_posts('posts_per_page=1&cat=15');
//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_titl开发者_如何学Pythone(); ?></a></h2>
<small><?php the_time('F jS, Y') ?></small>
<?php if ( has_post_thumbnail()) the_post_thumbnail('medium-thumbnail'); ?>
<div class="entry">
<p><a style="display: block;" rel="bookmark" href="<?php the_permalink(); ?>"><?php echo strip_tags(get_the_excerpt());?></a></p>
Sorry, no posts matched your criteria.
Thanks
@Sotiris
Sorry for the late reply only get to work on this site after working hours.
<div class="one_third">
<h2><a href="http://localhost:8888/edinburghshiatsuclinic/news-offers/news-letters-suday-test-post/." rel="bookmark" title="Permanent Link to News Letters Suday test post">News Letters Suday test post</a></h2>
<small>May 15th, 2011</small>
<div class="thumbnail"><a href="http://localhost:8888/edinburghshiatsuclinic/news-offers/news-letters-suday-test-post/." title="News Letters Suday test post"><img width="190" height="140" src="http://localhost:8888/edinburghshiatsuclinic/wp-content/uploads/2011/05/front-page3-200x147.jpg" class="attachment-medium-thumbnail wp-post-image" alt="front-page3" title="front-page3" /></a></div> <div class="entry">
<p><a style="display: block;" rel="bookmark" href="http://localhost:8888/edinburghshiatsuclinic/news-offers/news-letters-suday-test-post/.">Suspendisse tempus semper dignissim. Pellentesque ac tempus ligula. Aenean eu nisi eu mi consequat vehicula venenatis et leo. Praesent ornare aliquam ultricies. Nunc justo tellus, varius quis viverra a, scelerisque non justo. Suspendisse leo turpis, elementum in dignissim sed, facilisis … Continue reading →</a></p>
</div>
</div>
Well, based on the code you posted, everything in the div is a link already. If you want clicking anywhere on the div to work like a link, you'll need to use Javascript--can't really wrap a block-level element (<div>
) in an inline element (<a>
).
Here is a jQuery way to do that:
$('#one_third').click(
function(){
$(this).find('h2 a').click();
});
It just says "when you click on the div with id 'one_third'
, look for the element 'h2 a'
in it and trigger a click on that element. (I narrowed it down to just one of the links, if you didn't do that, if you just said ('a'
), it would click all the links. Which could be interesting as well.)
精彩评论