[Opgelost] Hoe toon ik alle URL's van berichten/pagina's op een WP-site (zoals een sitemap)?

  

3
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

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:

wordpress function om berichten en/of pagina's te tonen

Deel: