Transferred the site from the old version of Wordpress, the construction of the following type stopped working:

<?php ( get_the_term_list(get_the_ID, 'taxonomy_authors','',', ') )? printf( __( '<p class="hentry-tags">%1$s</p>', 'unspoken' ), get_the_term_list(get_the_ID, 'taxonomy_authors','',', ') ) : ''; ?> 

Previously, a list of tags from custom taxonomy. Now does not display anything. At the same time design:

 <?php echo get_the_term_list( get_the_ID(), 'taxonomy_authors', "" ) ?> 

works.

What can be wrong?

  • and in the first variant you have get_the_term_list(get_the_ID,... (i.e., the get_the_ID constant instead of the get_the_ID() function)?
  • The first option was fully working. But at the moment it does not display anything. In the example I took it from the code to check the performance. He is working now. The question is why the first option does not work now. - antohabio

1 answer 1

It seems you missed the get_the_ID() function call, and it always returns FALSE to you, since it cannot find the post, and in the construction in that case it displays '' is empty. It should be:

  <?php ( get_the_term_list(get_the_ID(), 'taxonomy_authors','',', ') )? printf( __( '<p class="hentry-tags">%1$s</p>', 'unspoken' ), get_the_term_list(get_the_ID, 'taxonomy_authors','',', ') ) : ''; ?>