我尝试在页面中添加帖子摘录但不在wordpress functions.php中添加的工作
v.8
我编写的这段代码摘录了
<div id="rightWindow" style="background-image: url('Images/<?php echo $randomPic; ?>');"
onclick="
var enable = function() { counter++;
if (counter > 7) {counter = 1;}
$( '#rightWindow' ).css('background-image', 'url(Images/<?php
echo $substring;
?>' + counter + '.jpg)');}
enable();
this.onclick = null;
$( '#rightWindow' ).on('transitionend',
function(e) {
alert('ended!');
this.onclick = enable;
});
"></div>
答案 0 :(得分:1)
<?php
$recent = new WP_Query( array(
'posts_per_page' => 5,
'order' => 'DESC',
) );
if ( $recent->have_posts() ) : while ( $recent->have_posts() ) : $recent->the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></h3>
<?php
the_excerpt();
endwhile;
endif;
wp_reset_postdata();
?>