How To Make Categorie Page In Wordpress ?

Discussion in 'HTML & Website Design' started by surimaribo, Apr 28, 2013.

  1. #1
    Hi,

    how do you make a page in wordpress that list a particular categories with it's child categories ?

    Lets say i have category "brands" and then the brand names as child categories, now when a user clicks on brands on the wordpress menu i like them to see all the brand names and post count in brackets next to the brand name
    Only if they click the brand name they will see the post that is written under that particular brand name .
     
    surimaribo, Apr 28, 2013 IP
  2. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    #2
    <?php query_posts('category_name=special_cat&showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <!-- Add category -->
    <?php endwhile;?>
    PHP:
     
    karthimx, Apr 28, 2013 IP
  3. surimaribo

    surimaribo Well-Known Member

    Messages:
    457
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Hi,
    So where exactly do i put this code?
     
    surimaribo, Apr 28, 2013 IP
  4. Devtard

    Devtard Notable Member

    Messages:
    850
    Likes Received:
    133
    Best Answers:
    4
    Trophy Points:
    220
    #4
    Devtard, Apr 28, 2013 IP
  5. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    #5
    where you need those category links to be published.
     
    karthimx, Apr 28, 2013 IP
    surimaribo likes this.
  6. surimaribo

    surimaribo Well-Known Member

    Messages:
    457
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #6
    I like these cat links to be published on a page that i will call brands.
    The category brand is already made with it's sub cats "brand names"
    When i add brands cat in my menu and click then it shows the posts of the brand name categorie.
    but i want to show the brand names so user can click the names they want and see the posts that are published there .
     
    surimaribo, Apr 29, 2013 IP
  7. cadavr

    cadavr Active Member

    Messages:
    97
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    90
    #7
    It seems like you're wanting this list to be shown on a page. There is a way to create templates for certain posts/pages.

    Here is the wordpress help page. http://codex.wordpress.org/Template_Hierarchy

    So lets say your brand page has the id of... 10... then in your theme directory you would create a file named page-10.php. Copy all the content from page.php to page-10.php then edit page-10.php with the line of code that karthimx provided. try placing the code just below <?php the_content(); ?>

    *** this is the longer version on how to edit the template file. you could skip all this and just do what devtard suggested.
     
    cadavr, Apr 29, 2013 IP
  8. surimaribo

    surimaribo Well-Known Member

    Messages:
    457
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #8
    Ok so i made a custom template called page-brands.php and installed categorie images so the page can display the images that links to the categorie posts .
    they are ordered by name in alphabetic order wich is good but i like to have the letters of the alpabet first and then the names in the alphabetic letter.

    Lets say letter A and then the brand names that start with letter A etc...
    This is what i have in my brands template

    <div id="container">
                <div id="content" role="main">
     
    <?php
    $args=array(
      'orderby' => 'name',
      'order' => 'ASC',
        'exclude' => '54,171,243,241,243,10,93,228,12,225,14,9,155,11,13,15,16,78,226',
    )
    ?>
    <?php foreach (get_categories( $args ) as $cat) : ?>
    <span class="grid"><h3><a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a></h3>
    <a href="<?php echo get_category_link($cat->term_id); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></a></span>
    <?php endforeach; ?>
    PHP:
    I also styled images in grid with this css code
    span.grid {
    width: 170px;
    display: block;
    float: left;
    margin-right: 14px;
    height: 190px;
    margin-bottom: 30px;
    overflow:hidden;
    }
     
    surimaribo, May 1, 2013 IP
  9. cadavr

    cadavr Active Member

    Messages:
    97
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    90
    #9
    cool. so its all working so far?

    you may just need to orderby title

    this wordpress codex page should prove useful in sorting your posts (products) alphabetically http://codex.wordpress.org/Alphabetizing_Posts
     
    cadavr, May 1, 2013 IP
  10. surimaribo

    surimaribo Well-Known Member

    Messages:
    457
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #10
    Order by title does not work
    I found an live example here http://supplementreviews.com/brands
    see #, A, B

    so under # you have brands that starts with a number
    A post that starts with A.

    On my site they are all in alphabetical order but i want to add the letters from the alphabet just like the example .

    How can i do that ?
     
    surimaribo, May 1, 2013 IP
  11. cadavr

    cadavr Active Member

    Messages:
    97
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    90
    #11
    Yes, I see exactly what you mean now.
    1- I don't know how to set this up using the standard wordpress functions. You would have to separate the groups of letters for your products then add the correct href/id combo for them to work.

    2-I'm about to make your day :) When you showed that example I remembered a plugin that basically does that same thing. You may have to tinker with the css a little bit, but it should work nicely! Try out this plugin here: http://www.dagondesign.com/articles/multi-column-category-list-plugin-for-wordpress/

    If memory serves, you'll install this plugin then edit the template for the page your products will be shown on (or perhaps you can just add a [shortcode] to that page). just make sure their stylesheet is linked properly or copy their stylesheet and add it to your main stylesheet so you won't have unnecessary files.
     
    cadavr, May 1, 2013 IP
    surimaribo likes this.
  12. creativewebmaster

    creativewebmaster Active Member

    Messages:
    654
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    78
    #12
    May this help you.

    <?php $catname = wp_title('', false); ?>
    <?php query_posts("category_name=$catname&showposts=3"); ?>
    <?php $posts = get_posts("category_name=$catname&numberposts=3&offset=0");
    foreach ($posts as $post) : start_wp(); ?>
    <?php the_title(); ?>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>
    Code (markup):
     
    creativewebmaster, May 1, 2013 IP
  13. Arick unirow

    Arick unirow Acclaimed Member

    Messages:
    719
    Likes Received:
    298
    Best Answers:
    30
    Trophy Points:
    500
    #13
    I always use this:
    <?php $cat = get_query_var('cat');  ?>
                <?php
                $categories=get_categories('parent='.$cat);
                if ($categories) {
                echo '<ol>';
                foreach($categories as $term) {
                echo '<li><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf($term->name ) . '" ' . '>' . $term->name.'</a></li>';
                // echo '<p>' . $term->description.'</p>';
                }
                echo '</ol>';
                }
                ?>
    PHP:
    It shows the category and any child category and even another child category of the child category (only when the category has posts in it). It will print description if you uncomment the echo about description above.

    Update: well, forget it, it only print category and child category. Didn't show up how many post it have and didn't show up the child category when user click it (just like archive in blogspot - user click it and post show up). My answer wasn't relevant. apology.

    Agreed. Executing PHP in post or page require special plugin.:)
     
    Last edited: May 1, 2013
    Arick unirow, May 1, 2013 IP