[Resolved] Why doesn’t any of my taxonomies show up?

Home Forums Support [Resolved] Why doesn’t any of my taxonomies show up?

Home Forums Support Why doesn’t any of my taxonomies show up?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #2341315

    Hey guys,

    I have a custom post type with 5 custom taxonomies. The taxonomies are reached through 4 menu items. When a menu item is clicked, **only** the content belonging to that taxonomy must show, except for the last one which I call “Others”. This taxonomy contains several subcategories (more will be added as time goes) and it must show contents from **all** subcategories.

    However, each one of these subcats must also be available through the menu. See table below


    – Subtax 1
    – Subtax 2
    – and so on…

    This is my problem:

    I want the taxonomy and its description to <u>always</u> show, no matter if tax is empty or not. Now only taxonomies that actually have content shows up, but it doesn’t show any actual posts. The ones that doesn’t contain any content yet only show the default generate_do_template_part('none'), and no taxonomy description.

    For this I’m using a customized GP archive.php template file (taxonomy-name.php). Also inside this file i’m calling get_template_part('template-parts/content', 'cpt_name-3grid') which is a custom template with cards inside a grid.

    My code:

     * The template for displaying Archive pages.
     * @package GeneratePress
    if ( ! defined( 'ABSPATH' ) ) {
        exit; // Exit if accessed directly.
    $terms = get_terms(array(
        'taxonomy'      =>  'radgivartyper',
        'hide_empty'    =>  false
        <div <?php generate_do_attr( 'content' ); ?>>
            <main <?php generate_do_attr( 'main' ); ?>>
                 * generate_before_main_content hook.
                 * @since 0.1
                do_action( 'generate_before_main_content' );
    ​            if ( generate_has_default_loop() ) {
    ​                if ( have_posts() ) :
    ​                 /*
    		* generate_archive_title hook.
    		* @since 0.1
    		* @hooked generate_archive_title - 10
                   		do_action( 'generate_archive_title' );
    ​                 /**
    		* generate_before_loop hook.
    		* @since 3.1.0
              ​       do_action( 'generate_before_loop', 'archive' ); ?>
                        <div class="itc-row gutter">
      			foreach($terms as $term) {
                          $args = array(
                            'tax_query'     =>  array(
                                'taxonomy'  =>  'radgivartyper',
                                'field'     =>  'slug',
                                'terms'     =>  $term->slug,
    ​                                    )
    ​                                )
    ​                            );
                          $agent_cat_posts = new WP_Query($args);
                          while ( $agent_cat_posts->have_posts() ) :
                          get_template_part( 'template-parts/content', 'radgivare-3grid' );
                          wp_reset_postdata(); }
    ​                    ?>
    ​                    </div>
    ​                    <?php
    			* generate_after_loop hook.
    			* @since 2.3
      			do_action( 'generate_after_loop', 'archive' );
      			else :
      			generate_do_template_part( 'none' );
                            /* End of foreach */
    			* generate_after_main_content hook.
    			* @since 0.1
    			do_action( 'generate_after_main_content' );
    * generate_after_primary_content_area hook.
    * @since 2.0
    do_action( 'generate_after_primary_content_area' );

    As you can see I’m (trying to) harnessing the power of get_terms() but obviously I’m doing something wrong since it’s producing no results, except for showing the description when there are posts in that taxonomy.

    Phuh! That’s a lot, sorry about that. I really need assistance her though. Thank you in advance.

    Customer Support

    Hi there,

    where can i see one of the problem archives ?


    See private info area


    Or rather this

    Customer Support

    I am not sure i have an answer for this as it falls into custom development.
    But my approach would be to use the default template hierarchy to set the query for you:


    For example if you were to

    1. just take a copy of the GP archive.php
    2. rename it to: taxonomy-{taxonomy}.php
    2.1 changing the {taxonomy} for the name of your taxonomy.

    eg. taxonomy-radgivartyper.php

    Then you should see the various taxonomy archives for each of the taxonomy terms you have set.

    If that works then the archive you want to show several sub categories in you can:

    1. Create another copy of the archive.php
    2. rename this to: taxonomy-{taxonomy}-{parent-term}.php
    2.1 changing the {taxonomy} for the name of your taxonomy.
    2.2 changing the {parent-term} for the parent term of your taxonomy.

    eg. taxonomy-radgivartyper-parentterm.php

    That should show all posts that are in the parent term and its children.

    Could you try that? If that works – Then we can look at the content template changes and keeping the description always visisble


    Hi David,

    Thank you, your example code works like a charm! I’m not surprised though 😉

    So now maybe we could find a solution to the empty categories with the dreaded “Nothing found” text then?


    Customer Support

    In your copies of the archive.php look for this line:


    delete that line and replace it with:

    do_action( 'generate_archive_title' );

    So in this instance instead of it loading the no-results.php – it will hook in the archive title and description.


    Well, I’m speechless. Things are so easy when you know what to do 😂

    Like always… big thank you David! You’re my hero 🍺

    Customer Support

    I am just super glad to hear it works 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.