Tagged: archive page, archive.php, custom taxonomies, taxonomies
-
AuthorPosts
-
July 5, 2018 at 12:08 pm #981547
Hi,
I am updating a 10 year old WP-Installation that relied heavily on custom taxonomies with almost 700 posts. I need to display several lines of custom taxonomies underneath the title for each posts when shown in archive lists and in single post view.
I already managed to do that in the search loop, no problem. See private link number one. See how underneath each title there is a huge number of custom taxonomies neatly displayed?
Thats the code I used in includes/loop-search.php (I deleted all the old code for displaying meta-information in this span-tag)
<span class='post-meta-infos'> <span style="width: 80px;display: inline-block;">AutorInnen:</span><?php echo get_the_term_list( $post->ID, 'autorin', '', ', ' ); ?><br> <span style="width: 80px;display: inline-block;">Methode</span><?php echo get_the_term_list( $post->ID, 'methode', '', ', ' ); ?> <br> <span style="width: 80px;display: inline-block;">Fachdidaktik:</span><?php echo get_the_term_list( $post->ID, 'fachdidaktik', '', ', ' ); ?><br> <span style="width: 80px;display: inline-block;">Schlagworte:</span><?php echo the_tags( '', ', ', ' ' ); ?><br> <span style="width: 80px;display: inline-block;">Schulform:</span><?php echo get_the_term_list( $post->ID, 'schulform', '', ', ' ); ?><br> </span>
I fail to do the same with any of the taxonomy archive-pages that you get when click one of the links underneath the titles, like with link number two. Same with single post view.
Can you point me to the right php-files? archive.php seems to relate to loop-index.php, but I cannot make heads or tails or where to put my code. Please note in this case that it’s not enough to just asign the blog-layout via functions.php, unless I can put my code somewhere that controls e.g. the elegant-theme for blog-lists.
Maybe hooks?
- This topic was modified 6 years, 5 months ago by Carqueville.
July 5, 2018 at 3:41 pm #981637In think I might have found a possible solution on my own, even though I had already put considerable hours into this before.
So there seems to be at least one way for displaying custom taxonomies under the title of a blog post.Right under line 211 to 214 in includes/loop-index.php there is a chance to include content outside a if-clause that governs part of the content-structure of blog-lists in Enfold.
After this:
// The wrapper div prevents the Safari reader from displaying the content twice ¯\_(ツ)_/¯ echo '<div class="av-heading-wrapper">'; echo strpos($blog_global_style, 'modern-blog') === false ? $cat_output.$title : $title.$cat_output; echo '</div>';
Before this:
echo $close_header;
I included this to show the custom taxonomy “autorin” right under the title:
echo '<span class="post-meta-infos">'; echo '<span style="width: 80px;display: inline-block;">AutorInnen:</span>'; echo get_the_term_list( $post->ID, 'autorin', '', ', ' ); echo '</span>';
Of course now I could include many more custom taxonomies right there.
I included the new loop-index.php in the enfold child theme. This way it shouldn’t be directly interfering with future updates. Of course using a hook seems the safer route, but I don’t see a way to include anything right under the title of blog posts. Or is there?
- This reply was modified 6 years, 5 months ago by Carqueville. Reason: copy-paste error
July 6, 2018 at 3:08 pm #982083Hi Carqueville,
Looks like there are no filters there, so this will be the way to do it.
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
VictoriaJuly 6, 2018 at 3:55 pm #982112Thanks. You can close this topic, i think. The solution will help others as well, i hope
July 6, 2018 at 6:27 pm #982166Hi,
Thread closed :)
Best regards,
Dude -
AuthorPosts
- The topic ‘Custom Taxonomies under post title on archive-pages, single post’ is closed to new replies.