<?php
$categories=get_categories('');
foreach($categories as $category) {
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
echo '<p> Cat ID: '. $category->cat_ID. '</p>';
// The Query
$id_cat = $category->cat_ID;
$args = array(
'cat' => $id_cat,
'showposts' => 5,
);
query_posts( $args );
// The Loop
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
}
// Reset Query
wp_reset_query();
Related Posts:
- Get post content intro text on category.php?
- Only one category per post
- Get rid of WordPress category, tag and author archives?
- How to get permalinks with category base working with sub-categories
- Filtering categories in the permalink structure
- get_categories hierarchical order like wp_list_categories – with name, slug & link to edit cat
- Why aren’t sub-categories nested after creating post in the WP Admin?
- Preventing index.php?category_name=something from redirecting
- How to get category id of current post?
- Programmatically create product category and add thumbnail in woocommerce
- How to order the get_categories result
- Categories’ hierarchy in URL
- How can I calculate the total number of categories at different hierarchy levels?
- How to get next previous category in same taxonomy?
- How to add a background image to category and display image on category page
- Display only deepest category on a single post?
- How we add new categories by wp_insert_post
- Show Subcategory Description
- I want exclude the particular category in sidebar
- Which php file lists all the post of a category
- wp_list_categories() – adding a div to each li?
- How to query posts from specific authors and categories using WP_query?
- Apply custom category template to subcategories
- How Can You Exclude Categories From Your RSS Feeds?
- Help with multiple dropdown tags search
- List Terms in Category
- Can you have a single set of “canonical” categories shared by all blogs?
- List Posts by Category for a Non-Zero, Non-NULL Custom Field Value?
- How to get category URL with the slug?
- Rename Default Category (Uncategorized) Via a Function
- How to customize category template?
- How get permalink for the current category or tag?
- Customized landingpages for categories
- get_the_category_list open in parent window
- Show category images on single product page and product overview page
- Category index featured image
- Class active for Archive link – looped out
- need to add custom field in more products
- Get parrent category name
- Display specific categories by ID
- Sorting category products not working
- Show category from “Next post” and “Previous post” [edited]
- Custom archive.php: retrieve right post categories?
- How to add WordPress sub category without select
- How to customize categories panel?
- Get posts from 2 different categories
- Custom taxonomy template for categories
- Show category with link
- Random Featured Image Based on Category
- Select posts from Category
- Display a list of subcategories a post belongs to
- Display unused categories in dropdown
- Show Pages in Categories
- get_posts ignoring ‘category’ and displaying all posts
- Get post related on category
- Give Children Unique ID’s
- Get paged category link programmatically
- Some of the category description not showing up in category page
- Function to automatically rename the base category permalink
- Add theme-color meta tag to head?
- How to get an array with all categories and corresponding names?
- WordPress Customizer: Dropdown with Category output
- Custom tax_query filter not working for Woocommerce product categories
- display a link to all the categories of current post, including parents
- Need to echo category id in multi-dimensional array
- Use blog as base for tags and categories
- Exclude parent category when getting category posts by slug
- category link not working for a specific slug, works for others
- Can’t iterate through 2 levels of categories
- Update custom category fields front-end
- Include last post date in get_categories loop
- Categories not posts at the frontpage
- Add Post Categories in Post Tags Field Programmatically
- How do I remove “Uncategorized” from my theme on my posts page?
- Conditional label Woocommerce archive [unsolved]
- Removing catagory for new blog pages
- Filter custom taxonomy posts via AJAX
- set a parent category in a product woocommerce
- “Next posts” of a category do not call category.php
- Trying to display all posts in a category
- Remove “Category:”
- A search box for all sites – Multisite
- How to grab posts from the most recently created category
- Match two taxonomies to display a specific content
- How to count the number of monthly archive?
- Modify / Rewrite single template url structure
- Most efficient use of custom taxonomies, categories, and pages
- AZ Directory category
- Make three menus with three category levels
- how to call the category of the post
- Category related -> excerpt, title and thumb in sidebar on article page
- How to have a category not show up in query post with page panigation?
- single category widget with conditional terms
- Remove the current item from a menu
- Show category-ID in custom category-list
- why is the delete option missing from just one category?
- Get all categories
- Show category post order ASC
- How to display all category images for single post in a page?
- Restricted category in Woocommerce [closed]