-
AuthorPosts
-
October 10, 2014 at 11:45 am #123139
Hello –
Can someone tell me how I can have my Renew child theme display the category’s name and description on the category page instead of the text “Category Archive”?
I’ve set up a child theme, and I imagine this is a fairly simple edit to the function.php page… I just have no idea what it would be
Thanks in advance!
-joeOctober 11, 2014 at 3:47 am #123421Hi there,
Please put this code inside function.php
<?php if ( is_category() ) : ?> <?php $meta = x_get_taxonomy_meta(); $title = ( $meta['archive-title'] != '' ) ? $meta['archive-title'] : __( 'Category Archive', '__x__' ); $subtitle = ( $meta['archive-subtitle'] != '' ) ? $meta['archive-subtitle'] : __( "", '__x__' ) . '<strong>“' . single_cat_title( '', false ) . '”</strong>'; ?> <?php endif; ?>
Hope it helps.
October 11, 2014 at 12:50 pm #123556Thanks for the code, but it didn’t do anything.
Any other suggestions?Much appreciated,
-joeOctober 12, 2014 at 4:34 pm #123874Hi there,
Have you tried editing your categories and changed their title and sub title?
Admin > Posts > Categories then choose a category then add your title and sub title.
Thanks.
October 14, 2014 at 9:42 am #124979> Have you tried editing your categories and changed their title and sub title?
Yes.
The “Archive Title” displays on the category page, regardless of whether or not I use your code. But I cannot get the description to display.
Any other suggestions?
Thank you,
joeOctober 14, 2014 at 2:20 pm #125207Try adding this instead
<?php if (is_category()) { ?> <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2> <br /> <?php echo category_description(); ?> <?php endif; ?>
October 14, 2014 at 8:06 pm #125383Thanks for the code, but no luck.
I tried simply testing “is_category” and also couldn’t get it to work:
<?php if ( is_category() ) { ?> <p>This is a category</p> <?php } ?>
Any other suggestions?
Thank you,
-joeOctober 15, 2014 at 8:14 am #125646Hi Joe,
Sorry for the confusion,
To change the category title, you need to copy and edit this file to your child theme x/framework/views/renew/_landmark-header.php.
Then you’ll see something like this, from line 57 to 66
<?php elseif ( is_category() || x_is_portfolio_category() || x_is_product_category() ) : ?> <?php $meta = x_get_taxonomy_meta(); $title = ( $meta['archive-title'] != '' ) ? $meta['archive-title'] : __( 'Category Archive', '__x__' ); ?> <h1 class="h-landmark"><span><?php echo $title; ?></span></h1>
You can then change it to something like this
<?php elseif ( is_category() || x_is_portfolio_category() || x_is_product_category() ) : ?> <h1 class="h-landmark"><?php single_cat_title(); ?> </span></h1> <p class="cat-desc"><?php echo category_description(); ?></p>
Hope that clarifies,
Have a great day
October 15, 2014 at 11:44 am #125813Perfect – just what I needed – thanks so much!
-joeOctober 15, 2014 at 5:41 pm #126005Glad we were able to help
October 10, 2015 at 3:13 am #619238This was helpful – Thank you!
October 10, 2015 at 3:19 am #619250You’re welcome.
January 29, 2016 at 8:28 am #770640Thanks for the help!
I have 2 questions:
1 | Is it possible to show the post thumpnails/excerpts above the category content instead of below?
2 | Is it possible to use cornerstone or shortcodes in the category content? Now i can only place content in the category with the standard wordpress editor..Thanks in advance!
Hans
January 29, 2016 at 4:18 pm #771286Hi Molmedia,
1. Sure possible, but instead of adding
<p class="cat-desc"><?php echo category_description(); ?></p>
to x/framework/views/renew/_landmark-header.php, it should be added at /x/framework/views/global/_index.phpLike this,
<?php pagenavi(); ?> <?php if ( is_category() ) :?> <p class="cat-desc"><?php echo category_description(); ?></p> <?php endif; ?>
2. You can’t use cornerstone, but yes, shortcode could be possible and you may change your code to
this.<?php pagenavi(); ?> <?php if ( is_category() ) :?> <p class="cat-desc"><?php echo do_shortcode( category_description() ); ?></p> <?php endif; ?>
Thanks!
February 3, 2016 at 5:31 am #777716Thanks for the quick response, It all worked great!
-
AuthorPosts