简体   繁体   English

如何显示WordPress站点中的所有页面

[英]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? 如何使wordpress自动粘贴页面名称,然后将其链接粘贴到锚标记中?

<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 谢谢

Use the get_pages function of wordpress. 使用wordpress的get_pages函数。

<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 
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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