Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created the 2 categories. And these two categories have child category, how can i get the post of the category when I clicked on the category title. Please guide me

share|improve this question
    
just simple call category in menu, when u click category post automatic call in loop –  vikas tyagi Apr 4 '13 at 4:53

1 Answer 1

up vote 0 down vote accepted
<?php
    // Get the ID of a given category
    $category_id = get_cat_ID( 'Category Name' );

    // Get the URL of this category
    $category_link = get_category_link( $category_id );
?>

<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" title="Category Name">Category Name</a>

After you click on the Category Title link, it will take you to the page where it displays all the posts under that category. Note: category.php, archive.php template files are responsible for the display, else index.php will be used.

share|improve this answer
    
I have included category.php, archive.php. It takes category.php but loop is not working, can u help me in that –  sindhu Apr 4 '13 at 5:48
    
I have created post in custom post type. Please guide me –  sindhu Apr 4 '13 at 5:54
    
If you are using custom post type, have you attached the category to it ? or any custom taxonomy/term ? Go through the template hierarachy here and you can modify the template loop. codex.wordpress.org/images/1/18/Template_Hierarchy.png Can you paste the code ? –  Subharanjan Apr 4 '13 at 6:48
    
I created custom taxonomy, used as $args = array('taxonomy' => 'product-categories', 'walker' => null, 'title_li' =>'', 'type' =>'products'); ?> <ul> <?php wp_list_categories($args); ?></ul> –  sindhu Apr 4 '13 at 6:50
    
I solved the issue, I created taxonomy-product-categories.php. Now the loop working fine –  sindhu Apr 4 '13 at 7:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.