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 .
<?php query_posts('category_name=special_cat&showposts=10'); ?> <?php while (have_posts()) : the_post(); ?> <!-- Add category --> <?php endwhile;?> PHP:
If you want to execute the code in a post you need to install a plugin that allows that. (e.g. http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/)
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 .
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.
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; }
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
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 ?
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.
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):
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.