WORDPRESS - Get only titles from specific category


/ Published in: PHP
Save to your folder(s)

Takes titles from a certain category and lists them in an unordered list.


Copy this code and paste it in your HTML
  1. <ul>
  2. <?php
  3. $cat_posts = get_posts('category=10&numberposts=-1');
  4. foreach($cat_posts as $post) : setup_postdata($post);
  5. ?>
  6. <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink to <?php the_title(); ?>">
  7. <?php the_title(); ?>
  8. </a></li>
  9. <?php endforeach; ?>
  10. </ul>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.