【发布时间】:2014-06-08 17:19:41
【问题描述】:
我试图在 Wordpress 页面上包含两件事:自定义帖子列表以及自定义帖子的内容。我希望自定义帖子的标题链接到包含帖子内容的页面部分。
例如:
- 项目一
- 项目二
- 项目三
第一项标题
第一项内容...
第二项标题
第二项内容...
第三项标题
第三项内容...
所以“Item One”会链接到“ITEM ONE HEADING”。这是我正在使用的代码,它显示了自定义帖子列表以及内容,但列表项链接到自定义帖子的页面。
<ul>
<?php
$query = new WP_Query( array( 'post_type' => array( 'drilling' ) ) );
while ( $query->have_posts() ) : $query->the_post();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
endwhile;
?>
</ul>
<?php wp_reset_query(); ?>
和
<?php query_posts( 'post_type=drilling'); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<section class="service-middle">
<div class="container">
<div class="service-middle-content sixteen columns">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php echo get_the_title($ID); ?> </h2>
<?php the_content(); ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<!-- /article -->
</div> <!--end service-middle-content-->
</div> <!--end container-->
</section> <!--end service-middle-->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
非常感谢您的帮助! -丹
【问题讨论】:
标签: wordpress post hyperlink anchor