user3479267
user3479267

Reputation: 232

How to display all pages in wordpress site

How do I get wordpress to automatically paste in the pages names and then their links in the anchor tags?

<header>

    <div class="container">

        <div class="header-left">

            <a href="<?php echo get_option('home'); ?>"><h1><?php echo $blog_title = get_bloginfo('name'); ?></h1></a>

            <h2><?php echo get_bloginfo ( 'description' );  ?></h2>

        </div>

        <div class="header-right">

            <a href="<?php ** Page Link Here ** ?>" class="header-link"><?php ** Page Name Here ** ?></a>
            <a href="<?php ** Page Link Here ** ?>" class="header-link"><?php ** Page Name Here ** ?></a>
            <a href="<?php ** Page Link Here ** ?>" class="header-link"><?php ** Page Name Here ** ?></a>
            <a href="<?php ** Page Link Here ** ?>" class="header-link"><?php ** Page Name Here ** ?></a>

        </div>

    </div>

</header>

Thanks

Upvotes: 0

Views: 2907

Answers (1)

nicowernli
nicowernli

Reputation: 3348

Use the get_pages function of wordpress.

<div class="header-right">
<?php
$pages = get_pages();
foreach ( $pages as $page ) {
?><a href="<?php echo get_page_link( $page->ID ) ?>" class="header-link"><?php echo $page->post_title ?></a><?php 
}
?>

Upvotes: 4

Related Questions