Community Forums › Forums › Archived Forums › General Discussion › Displaying info on Category Pages differently
Tagged: categories, category, filter, functions, genesis hooks
- This topic has 4 replies, 3 voices, and was last updated 11 years, 4 months ago by Summer.
-
AuthorPosts
-
September 17, 2013 at 9:23 pm #63117slydawggMember
I was curious if there was any hooks or functions in Genesis that I am overlooking to display category pages differently based on the category... I am sure there is a way to do it using WordPress, but I haven't been able to make it work either b/c I am probably over-thinking it.
I've created a category.php template to display my Posts based on whatever their category is.What I want to do is this:
If (all categories)
show titles of post for all categories
if (only categoryA selected and showing)
filter to show titles for categoryA only
if (only categoryB selected and showing)
filter to show titles for categoryB only
and so on...====================
Currently I have something like this, so I am looking for a better and more efficient way to do it.<?php if ( is_category('20') ) { echo '<h1>'; printf( __( 'This is Category A', 'genesis' ), home_url() ); echo '</h1>'; } ?>
<?php if ( is_category('25') ) { echo '<h1>'; printf( __( 'This is Category B', 'genesis' ), home_url() ); echo '</h1>'; } ?>
====================
This doesn't seem very efficent, especially if you have 10 or more categories.
I know if I dowp_get_archives()
I can see all posts but I am not sure the best way to filter based on Category; but I don't think there is a parameter to filter what I am trying to do
Any suggestions?
September 17, 2013 at 10:08 pm #63120Sridhar KatakamParticipantSeptember 18, 2013 at 7:07 am #63172slydawggMemberSridhar,
This is very close to what I am trying to do because it does display the category name, but I still need it to do one thing.I need it to filter the Posts found within those categories; looks like I didn't say that in my above code.
So...
if (all categories)
show all Posts by displaying the title of each post, as a list.
if(CategoryA)
show only CategoryA posts as a list)
if(CategoryB)
show only CategoryB posts as a list)
etc...Let's say my Categories are Apples and Grapes; I would want to have a page that filters out:
This is the Apples Category (title of Category)
>Red Apples (title of Post)
>Green Apples (title of Post)
>Apple Pie (title of Post)
>etc...This is the Grapes Category (title of Category)
>White Grapes (title of Post)
>Red Grapes (title of Post)
>Wine Grapes (title of Post)
>etc...The is ALL Categories (displaying all Categories on one page)
>Red Apples (title of Post)
>Green Apples (title of Post)
>Apple Pie (title of Post)
>White Grapes (title of Post)
>Red Grapes (title of Post)
>Wine Grapes (title of Post)I hope this makes sense, and you can assist
September 18, 2013 at 8:47 am #63202Sridhar KatakamParticipantSeptember 18, 2013 at 10:05 am #63218SummerMemberYou could make separate templates based on each category you want to customize... that's the "WordPress" way, anyway 🙂
So, you'd have separate templates, say category-grapes.php, category-apples.php, and the templates should just pull the category as the title, and you wouldn't have to do anything special with conditionals. Then just leave category.php for everything & the kitchen sink, and you should be good.
See this to start: http://codex.wordpress.org/Template_Hierarchy#Category_display
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After Dark -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.