3
07/11/2024 8:43 am
Onderwerp starter
Hallo - Ik zou graag willen weten hoe ik alle URL's van alle berichten (of/en pagina's) van een site kan laten zien (het CMS is WordPress).
Zoiets als XML sitemap maar dan met alle pagina's permalinks op één WP pagina.
Misschien als function....
Bedankt
1 antwoord
2
07/11/2024 8:45 am
Hier is de code:
$allPostsWPQuery = new WP_Query( array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => - 1 ) ); ?> <?php if ( $allPostsWPQuery->have_posts() ) : ?> <ul> <?php while ( $allPostsWPQuery->have_posts() ) : $allPostsWPQuery->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_permalink(); ?></a></li> <?php endwhile; ?> </ul> <?php wp_reset_postdata(); ?> <?php else : ?> <p><?php _e( 'There no posts to display.' ); ?></p> <?php endif; ?>
Op regel #2 in plaats van:
'post_type'=>'page'
kun je typen:
'post_type'=>'post'
om alle berichten van je site te zien.
Hier is het resultaat in de browser: