user2750585
user2750585

Reputation:

how to get all the id's of posts made under specific category in wordpress

I am trying to get all the ID's of posts which I have made in a specific category.

I have created a category in WordPress e.g web-articals.

I have created some posts and linked those with web-articals category. Now I want to display the content of post whichI have created inside that category and for that I want all the post ID's inside that category.

How can I get ID's off all the post inside of web-articals category?

<?php

query_posts( array ( 'category_name' => 'web articals', 'posts_per_page' => -1, 'order' => ASC  ) );

// The Loop
while ( have_posts() ) : the_post(); ?>

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

// Reset Query
wp_reset_query();

?>

I have tried this but dis way of doing it but dis dispalys only the title of the posts in unordered list: e.g

but i want somthing which look like

"content of my post frame works"

" content ofmy post Open Source"

"content of my post"

Upvotes: 2

Views: 1931

Answers (2)

user2750585
user2750585

Reputation:

it works guys here i leave ans for some1 to get help from it.

    <?php

query_posts( array ( 'category_name' => 'web articals', 'posts_per_page' => -1, 'order' => ASC  ) );

// The Loop
while ( have_posts() ) : the_post(); ?>
    <!--echo '<li>';
    the_title();
    echo '</li>';-->
    <li>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" ><?php the_title(); ?></a> <?php echo get_post_field('post_content',  the_ID());

 ?>
      </li> 
      <?php
endwhile;

// Reset Query
wp_reset_query();

?>

thanks huys for help

Upvotes: 2

Desh
Desh

Reputation: 175

I hope below are the posts of web articals

Frame Work <----- these are my post titles
Open Source
Model–View–Controller (MVC)

If it is so, then use the_ID() function like you have used the_title();.

Upvotes: 1

Related Questions