Community Forums › Forums › Archived Forums › Design Tips and Tricks › snippet for functions.php to show category name
Tagged: custom category, show category name
- This topic has 9 replies, 2 voices, and was last updated 9 years, 3 months ago by babrees.
-
AuthorPosts
-
January 15, 2015 at 5:22 am #137519babreesParticipant
As the title says 🙂
I want to add a snippet of code to the functions.php so that the category name and description will show on ALL categories, without my having to go in to edit and add it manually to each one.
PLUS, I have a custom category type (Judges) that I want to do the same for
Any ideas?
Cheers
JillJanuary 15, 2015 at 10:49 pm #137624Ren VenturaMemberHi, Jill. I just typed this up. Hopefully it's what you are looking for.
http://www.engagewp.com/how-to-display-category-name-description-genesis/
Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren
January 16, 2015 at 12:30 am #137633babreesParticipantHi Ren. Thanks!
It does add the category but puts it in the sidebar and with no formatting. I can easily do the formatting by adding divs but how to ensure it goes in the content area, not the sidebar?
Also, can you help with doing that for a custom category type, called "Judges" ?
😀
January 16, 2015 at 12:44 am #137634Ren VenturaMemberI'm not sure why it would show up in the sidebar, especially without seeing your site. You can play around with the code and change the hook its using to something else (see the Visual Hook Guide).
http://genesistutorials.com/visual-hook-guide/category/category-1/
When you say custom category, is it a normal post category or is it something different? If it's a category under your Posts, the code will work for it like all the others. I guess I just need some additional explanation so I know exactly what you're trying to do.
Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren
January 16, 2015 at 12:58 am #137637babreesParticipantHi Ren! Thanks again!
I changed the before_content to before_entry - that works 🙂 At the moment, the site is in early stages of development and you won't see anything different to the magazine-pro theme at the front end.
It is a custom taxonomy - category type. Not sure how else to describe it! In admin area, yes, it comes under posts in its own right and I add normal posts to it and it behaves like a category. However, your snippet on works for the default categories, NOT the custom one.
January 16, 2015 at 1:11 am #137638babreesParticipantOK, I've changed the is_category line to: if ( is_tax( 'judges' ) )
That works but I can't get it working with is_category and the default categories don't work with is_tax!
I'm stumbling a bit in the dark here.
Would you be able to help me with adding something like the following?
if ( is_tax( 'judges' ) )
AND
if (is_cat)January 16, 2015 at 1:17 am #137640Ren VenturaMemberThanks for the clarification. I updated the post/snippet to work with other taxonomies (tags and custom). Give it a shot.
Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren
January 16, 2015 at 1:41 am #137641babreesParticipantYES! BRILLIANT!
Thank you so much Ren, I appreciate your help!
I LOVE learning something new 😀
Cheers
JillJanuary 16, 2015 at 12:13 pm #137685Ren VenturaMemberJanuary 22, 2015 at 12:20 am #138242babreesParticipantJust a small update for anybody else who might want this. You need to use before_loop, not before_content.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.