【发布时间】:2014-11-20 16:58:38
【问题描述】:
$args = array( 'post_type' => 'object', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo "<div class=\"item\"><a href=\"" . the_permalink() . "\">" . the_title() . "</a></div>";
endwhile;
我在 WP 中的这个循环没有回显
<div class="item"><a href="#mylink">The name of my link</a></div>
而是
#mylink The Name of my link
<div class="item"><a href=""></a></div>
我错过了一些琐碎的事情吗?
【问题讨论】:
-
这里,既然您没有与任何变量链接,那么在 while 循环内回显有什么用?
-
它正在返回正确的链接和我的链接的正确名称...CPT 名称是 Object 是什么意思?
-
@Indra 抱歉,编辑了问题。
-
@NabilKadimi 是的,我正在尝试循环浏览我创建的自定义帖子类型的帖子。
标签: php wordpress concatenation