2013-06-26 45 views
0

我正在使用一段php来回显几个类别中的所有帖子。Wordpress自定义blog_query

$blog_query = 'showposts=100&cat=8&paged='.$paged; 
$posts = query_posts($blog_query); 
while (have_posts()) : the_post(); 
endwhile; 

它回应了标题和帖子内容的帖子。

我想编辑该函数,以便我可以用自己的自定义格式(无需发布内容)回显内容。

<ul id="customList"> 
<li><a href="[POST LINK]">[POST TITLE]</a></li> 
<ul/> 

回答

3
<ul id = "customList"> 
<?php 
$blog_query = 'showposts=100&cat=8&paged='.$paged; 
// The Query 
query_posts($blog_query); 
// The Loop 
while (have_posts()) : the_post(); ?> 

<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> 

<?php endwhile; 
// Reset Query 
wp_reset_query(); 
?> 
</ul> 

我上面的代码测试

OUTPUT将在格式:

<ul id="customList"> 
<li><a href="[POST LINK]">[POST TITLE]</a></li> 
<ul/> 
+0

我尝试使用该代码并将其返回:致命错误:允许存储器大小33554432字节耗尽(试图分配14520321字节) –

+0

嗨PhilipK,我编辑了我的代码,希望它能帮助你 – Denish