简体   繁体   中英

How do I list wp posts with releated images?

I would like to list posts in Wordpress and related images. How do I write the mysql_query($ask) in mysql?

I can join two tables but not sure how to do it as I need to use wp_posts two times via wp_postmeta, as I understand it.

You don't need to create a custom handmade query to perform this. You only need to run the Wordpress loop and get the releated images for each post. Try this simple code :)

<?php if ( have_posts()) : while ( have_posts() ) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <?php the_post_thumbnail(); ?>
<?php endwhile; endif; ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM