Philip Kirkbride
Philip Kirkbride

Reputation: 22899

Wordpress Customize blog_query

I'm using a snippet of php to echo out all the posts in a few categories.

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

It echos out the posts with title and post content.

I want to edit the function so that I can echo the contents out in my own custom format(without post content).

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

Upvotes: 0

Views: 185

Answers (1)

Denish
Denish

Reputation: 2810

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

I tested above code

OUTPUT will be in format of:

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

Upvotes: 3

Related Questions