Community Forums › Forums › Archived Forums › Design Tips and Tricks › Category heading above content and next to sidebar
- This topic has 8 replies, 3 voices, and was last updated 13 years, 4 months ago by
SoZo.
-
AuthorPosts
-
February 2, 2013 at 2:48 am #17319
stl99
MemberHi there,
I'm using the following code found in the StudioPress forums to display a heading on category pages. The problem is that the heading is displayed above the content AND above the sidebar. Even when I reduce the width of the heading the sidebar keeps being pushed down instead of being at the same level as the category heading.
<code>
/** Display category title */
add_action ( 'genesis_before_content','my_category_title' );
function my_category_title() {
if ( is_category() ) {
$term = get_category(get_query_var('cat'),false);
$name = $term->name;
echo '<h4 class="widgettitle"><span class ="widget-headline">'. $name .'</span></h4>';
}
}<code>
I already tried several other hooks but no luck so far - any ideas?
Cheers,
Thomas
February 2, 2013 at 6:32 am #17327Brad Dalton
ParticipantNot sure exactly where you got that code but you may be interested in another solution.
You can add text using the Archive Headline & Archive Intro Text fields for each category.
Another option is to install a plugin which also enables you to add HTML and images before your category archive pages.
Rich Text Tags, Categories, and Taxonomies plugin
This tutorial includes the correct code for adding a widget anywhere there;s a Genesis hook and you can change the conditional tag.
February 2, 2013 at 9:01 am #17349stl99
MemberActually I didn't know about the Archive Headline & Archive Intro Text fields feature which does exactly what I want - thanks!
If only there was a way to display the correct taxonomy names automatically instead of filling them all in manually...
Cheers,
Thomas
February 2, 2013 at 7:47 pm #17505Brad Dalton
ParticipantFebruary 3, 2013 at 3:48 am #17578stl99
MemberThanks for your help and last question:
I definitely have to insert the title for each category manually? Is there no way to have the category title automatically returned and only the description inserted manually?
Cheers,
ThomasFebruary 3, 2013 at 7:57 pm #17727Brad Dalton
ParticipantThere is a way to do pretty much anything with WordPress but i don't have the answer at the moment. Try wordpress.stackexchange.com
February 3, 2013 at 8:02 pm #17729SoZo
MemberYou can put this in functions.php
add_action('genesis_before_loop', 'add_cat_title'); function add_cat_title() { if(is_category()) echo single_cat_title(); }Add divs and style rules to suit.
John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography
February 4, 2013 at 2:42 am #17786stl99
MemberThanks, that finally worked!
February 4, 2013 at 8:19 am #17836SoZo
Member -
AuthorPosts
- The topic ‘Category heading above content and next to sidebar’ is closed to new replies.