![]() |
|
Home | Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
![]() In this tip, I will explain how to make a multi-column listing of your categories. This is useful for embedding in your website's footer or on a 404 page.
It will involve a lot of PHP so if you are already feeling squeamish ![]() ![]() The first step is to open up your theme's functions.php file. This can usually be found here: ~/wp-content/themes/YOUR-THEME/functions.php. If it's not there, ask your theme developer because all themes are different. Add the following 3 snippets of code to the functions.php file: 1. This function returns the total number of categories in your store. PHP Code:
PHP Code:
PHP Code:
Open the Custom CSS page and paste the following CSS code into the textarea. Code:
#cats_in_cols .modwrp {padding:0;margin:0;border:0;float:left;} #cats_in_cols .col1 {width:99.9%;} #cats_in_cols .col2 {width:49.9%;} #cats_in_cols .col3 {width:33.3%;} #cats_in_cols .col4 {width:24.9%;} #cats_in_cols .col5 {width:19.9%;} #cats_in_cols .modwrp .modcont {margin:0 10px 10px 0px;padding:5px;} Name the new view: cats_in_cols. Check the "Don't use layout for this view" checkbox. Add cats_in_cols to the Custom CSS ID field. Your view should be configured like this: ![]() Drag a "Category list" module into the module area. Click the template icon for the "Category list" module and paste in the following code: HTML Code:
<?php global $dfr_category_data_count; ?> <div class="modwrp col3"> [category.list before='' after='' id='catcols'] <?php global $dfr_category_data_count; $dfr_category_data_count++; ?> <a href="[category.link]" title="[category.name]">[category.name]</a><br /> <?php if ($dfr_category_data_count % dfr_number_of_categories_per_column('col3') == 0) { ?> </div><div class="modwrp col3"> <?php } ?> [category.repeat id='catcols'] [/category.list] </div> Save the module changes. If you are embedding your category columns into the footer of your blog, you will need to open your theme's footer.php file (or whatever file handles rendering the bottom of your blog pages) and paste in the following code wherever you want the category list to appear: PHP Code:
Update your store. That's it. ![]() Multi-column lists are NOT easy in any case, that's why this is not actually a proper html list. For further reading, I recommend this: http://www.alistapart.com/articles/multicolumnlists/ Eric
__________________
![]() ![]() ![]() ![]() |
#2
|
|||
|
|||
![]() In the end I decided to just list the categories separated by a dash...
I used the following code: Code:
<h2>Our shop categories are:</h2> <br> <!-- Category List --> [category.list id='list1'] <?php if ($nn > 1) { echo '- '; } ?> <a href="[category.link]" title="[category.name]">[category.name]</a> [/category.list] <!-- /Category List --> Code:
Our shop categories are: Category 1 - Category 2 - Category 3
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out. Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers. |
#3
|
|||
|
|||
![]() On my site http://www.phoneandtabletcases.com I want the next 4 company logos (htc, dell, etc) to appear next to the ones that are already there instead of below them. Do I need to follow the directions in this thread for that?
Last edited by isler45 : March 17th, 2011 at 03:01 PM. |
#4
|
||||
|
||||
![]() Hi
Yes, I think this will work for your purposes. Eric
__________________
![]() ![]() ![]() ![]() |
#5
|
|||
|
|||
![]() I am having some trouble getting this to work right. By default it seems like it is working. Then when I change the Category list in cats_in_cols to show only parent categories nothing shows up. Any ideas?
|
#6
|
||||
|
||||
![]() Try just setting the "Maximum tree depth" to 1.
__________________
![]() ![]() ![]() ![]() |
#7
|
|||
|
|||
![]() I seem to be having much better luck editing the default template 6 in the category list module.
[category.list id='dfcatcol3' before='<div class="cl">' after='</div>'] <div class="cell col3"> <div class="bdr"> <br /> <div class="catdesc"><a href="[category.link]" <img src="[category.thumbnail]" alt="[category.name]"></a></div> [category.list id='dfcatcol3' before='<ul>' after='</ul>'] <li> <a href="[category.link]" title="[category.name]">[category.name]</a> [category.repeat id='dfcatcol3'] </li> [/category.list] </div> </div> [/category.list] I really only know some basic html so I don't know what I am doing lol. I feel like its almost perfect. Is there a simple way to center images from top to bottom using this method? Any help from anyone would be appreciated. http://www.phoneandtabletcases.com (There you can see how the nokia and kyocer logos are a bit off, and I guess I need a smaller apple logo) |
#8
|
||||
|
||||
![]() Hi
To get the images more vertically centered, you should probably remove the extra <br /> tag. Eric
__________________
![]() ![]() ![]() ![]() |
#9
|
|||
|
|||
![]() Eric can adpat this techique to get a dynamically generated list of brands?
|
#10
|
||||
|
||||
![]() Quote:
__________________
![]() ![]() ![]() ![]() |
#11
|
|||
|
|||
![]() Quote:
|
#12
|
||||
|
||||
![]() That could prove to be even more difficult!
![]()
__________________
![]() ![]() ![]() ![]() |
#13
|
|||
|
|||
![]() Lookin for a little help if possible.I am running a child theme and cant get this to work i think because i need to do a add_action to the function.Would you know what i need to put into it.Any help highly appreciated .
Example from functions.php = add_action("after_setup_theme", "suffu_scion_theme_setup", 15); Thanks |
#14
|
||||
|
||||
![]() Hi
I really don't know about that. I would ask the theme developer as it seems theme specific. Eric
__________________
![]() ![]() ![]() ![]() |
#15
|
|||
|
|||
![]() ok thanks thought it was just a php action ,I dont know much about it.
|
Thread Tools | Search this Thread |
Display Modes | |
|
|