$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - Display Category description|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Display Category description

matteradmin8PV0评论

I want display category description only the first page:

I use in my category.php:

<?php if(category_description()) :?>    
<section class="cat-desc"> 
<?php echo category_description(); ?>
</section>
<?php endif; ?>

I try this:

   <?
   if (is_category()) {
   $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
   if ($page == 1) {
   echo category_description(); //you don't need to include the category id 
    on the actual category page - wordpress figures it out. 
   }
   }
  ?>  
  <?
  if (is_tag()) {
  $page2 = (get_query_var('paged')) ? get_query_var('paged') : 1;
  if ($page2 == 1) {
  echo tag_description(); //you don't need to include the category id on the 
  actual category page - wordpress figures it out. 
  }
  }
  ?> 

With the Category description is all ok but the tag description is missing.

Thanks.

I want display category description only the first page:

I use in my category.php:

<?php if(category_description()) :?>    
<section class="cat-desc"> 
<?php echo category_description(); ?>
</section>
<?php endif; ?>

I try this:

   <?
   if (is_category()) {
   $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
   if ($page == 1) {
   echo category_description(); //you don't need to include the category id 
    on the actual category page - wordpress figures it out. 
   }
   }
  ?>  
  <?
  if (is_tag()) {
  $page2 = (get_query_var('paged')) ? get_query_var('paged') : 1;
  if ($page2 == 1) {
  echo tag_description(); //you don't need to include the category id on the 
  actual category page - wordpress figures it out. 
  }
  }
  ?> 

With the Category description is all ok but the tag description is missing.

Thanks.

Share Improve this question asked Nov 15, 2018 at 4:02 JesúsJesús 31 bronze badge 2
  • Are you sure the tag actually has a description? And category.php is for category archives - for tag archives, use tag.php. – Sally CJ Commented Nov 15, 2018 at 5:06
  • Thnaks!! I addes tag.php (my theme wasnt added it). – Jesús Commented Nov 15, 2018 at 8:33
Add a comment  | 

1 Answer 1

Reset to default 0

After adding descriptions to your tags, modify your WordPress theme to display the description at the top of each archive page. Open the "Appearance" section of your WordPress website's main menu and select "Editor." Click the "tag.php" link under "Tag Template" on the right side of the page.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far