Advertisement
alchymyth

all pages, posts, categories with title and ID

Jan 19th, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2. $all_pages = get_pages(); //lookup http://codex.wordpress.org/Function_Reference/get_pagesfor the parameters to get all pages
  3. if($pages) :
  4. echo '<ul>';
  5. foreach( $all_pages as $page ) {
  6. echo '<li>';
  7. echo $page->post_title.' - '.$page->ID;
  8. echo '</li>';
  9. }
  10. echo '</ul>';
  11. endif;
  12.  
  13. $all_posts = get_posts(); //lookup http://codex.wordpress.org/Template_Tags/get_posts for the parameters to get all posts
  14. if($posts) :
  15. echo '<ul>';
  16. foreach( $all_posts as $post ) {
  17. echo '<li>';
  18. echo $post->post_title.' - '.$post->ID;
  19. echo '</li>';
  20. }
  21. echo '</ul>';
  22. endif;
  23.  
  24. $all_cats = get_categories(); // http://codex.wordpress.org/Function_Reference/get_categories
  25. if($all_cats) :
  26. echo '<ul>';
  27. foreach( $all_cats as $cat ) {
  28. echo '<li>';
  29. echo $cat->name.' - '.$cat->term_id;
  30. echo '</li>';
  31. }
  32. echo '</ul>';
  33. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement