- This topic has 6 replies, 2 voices, and was last updated 1 year ago by
Tom.
-
AuthorPosts
-
April 6, 2020 at 3:54 pm #1229141
johnaps
Hello!
I ve triedfunction db_page_hero_excerpt() { ob_start(); global $post; if ( has_excerpt( $post->ID ) ) { ?> <div class="page-hero-excerpt"> <?php echo the_excerpt(); ?> </div> <?php } return ob_get_clean(); } add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );
To get category description on my category pages but i dont get nothing.
Also on author archive pages i have added a shortcode from a plugin for the author box and it doesnt work
http://thefinterestcom.kinsta.cloud/author/johnitos/
Any idea why? As i have seen in other threads shortcodes should work right?
April 6, 2020 at 5:57 pm #1229207Tom
Lead DeveloperLead DeveloperHi there,
For it to work on your category pages, you’ll need to use
term_description();
instead ofthe_excerpt()
: https://developer.wordpress.org/reference/functions/term_description/Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 7, 2020 at 6:01 am #1229738johnaps
Hey Tom! I made the code as it follows based on your advice
function db_page_hero_excerpt() { ob_start(); global $post; if ( has_excerpt( $post->ID ) ) { ?> <div class="page-hero-excerpt"> <?php echo term_description(); ?> </div> <?php } return ob_get_clean(); } add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );
But i still dont get category desription to show…
Also you didnt tell me why simple shortcodes generated by a plugin (simple author box) arent working on pagehero header…?April 7, 2020 at 10:00 am #1230157Tom
Lead DeveloperLead DeveloperTry this:
function db_page_hero_excerpt() { ob_start(); ?> <div class="page-hero-excerpt"> <?php echo term_description(); ?> </div> <?php return ob_get_clean(); } add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );
Can you share the author shortcode you’re using?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 7, 2020 at 12:28 pm #1230325johnaps
Thank you for the code it worked! π
Simple Author Box i am using!
shortcode = [simple-author-box]
test page = thefinterestcom.kinsta.cloud/author/johnitos/April 7, 2020 at 2:55 pm #1230476johnaps
Fixed it! Thank you for all your help π
April 7, 2020 at 5:16 pm #1230565Tom
Lead DeveloperLead DeveloperNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.