- This topic has 7 replies, 2 voices, and was last updated 3 years ago by Tom.
-
AuthorPosts
-
May 1, 2020 at 4:05 am #1264492David
Hello
I’ve added a custom post type called projects and also a taxonomy for the categories called projects-category
I’ve then set up…
single-projects.php
archive-projects.php
content-projects.php
taxonomy-projects-category.phpAnd set the archive-projects.php and taxonomy-projects-category.php to call in the contents-projects.php now if I try and show the category description below the title header on the category pages it doesn’t show up.
http://185.20.51.60/~bentleysbuilders/projects-category/extensions-renovations/
If I add this to the archive-projects.php page nothing shows…
<?php the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?>
If I add it to the content-projects.php file it shows the description twice…
<?php /** * The template for displaying posts within the loop. * * @package GeneratePress */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <?php the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?> <div class="grid-50 tablet-grid-50 mobile-grid-100"> <?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><div class="projects-archive-outer"> <div class="project-archive-title"> <!-- POST TITLE --> <h2><?php the_title(); ?></h2> </div> <div class="projects-archive-inner" style="background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) 10%, rgba(96, 97, 97, 0) 100%), url('<?php echo $backgroundImg[0]; ?>') no-repeat; background-position: center;background-size: cover;"> </div></div></a> </div>
How do I get it to only show up once?
Thanks
DaveMay 1, 2020 at 9:24 am #1265146TomLead DeveloperLead DeveloperAdding it to the content.php file will loop it (as you’ve found out).
Maybe
the_term_description()
would work better?May 1, 2020 at 11:04 am #1265284DavidHi Tom
This worked…
<?php the_archive_description( '<div class="taxonomy-description">', '</div>' ); ?>
Just needed to add it to taxonomy-projects-category.php not the archive-projects.php for it to appear on that page.
Thanks for your help though.
Dave
May 1, 2020 at 5:23 pm #1265566TomLead DeveloperLead DeveloperGlad you got it working π
April 16, 2021 at 8:15 am #1737219TonyHi,
I have archive-video.php and I’m using
the_archive_description( '<div class="taxonomy-description">', '</div>' );
.The description shows, but it shows outside of
<header class="page-header"> </header>
How can I show it inside of that element?
Thank you
April 17, 2021 at 8:11 am #1738174TomLead DeveloperLead DeveloperYou would use this hook:
generate_after_archive_title
So:
add_action( 'generate_after_archive_title', function() { if ( is_post_type_archive( 'video' ) ) { the_archive_description( '<div class="taxonomy-description">', '</div>' ); } } );
April 19, 2021 at 3:58 am #1739914TonyThat helped, thanks! I wrote you a 5* feedback in the WP plugins directory. You deserve it π
April 19, 2021 at 8:02 am #1740458TomLead DeveloperLead DeveloperThank you! Really appreciate it π
-
AuthorPosts
- You must be logged in to reply to this topic.