Support » Plugin: A-Z Listing » Add Taxonomy title to index name

  • Resolved thefatgamer


    Hi Daniel,

    Firstly, fantastic plugin!

    I operate a gaming review website for retro-games – as you can imagine, there are game names that are the same across multiple platforms. Therefore, when all games are listed in the master index, they appear twice (which is correct) but the visitor doesn’t know what platform (aka category) the game is in until they click on the post name and visit the game page.

    I’m thinking of creating individual game-indexes for each platform using this shortcode: [a-z-listing post-type=”post” taxonomy=”category” terms=”atari-2600″] to get around this, however my question is it possible to include the category (or even tag) name in the name of the post?

    So the index might read:

    Castlevania [NES]
    Castlevania [Nintendo 64]

    Many thanks!


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Daniel Llewellyn


    Yes, this can be achieved, but it might break because of resource limits on your server. It is a heavy operation and the larger the listing the more resource intensive the process.

    With that caveat aside, the way to do it is to copy the template from the plugin folder at templates/a-z-listing.php into your theme and adjust it slightly.

    On line 37 (in version 2.1.0) you will need to insert a new line after the opening <?php tag with:

    $post = $a_z_query->get_the_item_object( 'I understand the issues!' );

    The text I understand the issues! must be exactly that for the plugin to accept that you really have read my warning about it potentially being slow or breaking due to resource constraints, or both.

    Once you have the $post you can edit line 58 (again in version 2.1.0) to append the following on a new line:

    $terms = get_the_terms( $post, 'category' );
    if ( $terms ) :
        echo '[' . esc_html( implode( ', ', $terms ) ) . ']';

    Thanks Daniel,

    I understand about the server load – I’ll evaluate the impact and that will dictate if I use it or not.

    I’ll have a go at implementing – I’ll mark off as resolved for now.


    Hi Daniel,

    Your plugin is really good but i have some more things to be displayed which involved displaying the name of the category that i have mentioned in wp_terms.
    I am trying to get the name field of wp_term and display it with the title.

    How do I try to get this name in the array

    Plugin Author Daniel Llewellyn


    Sorry, my code above was incorrect. To show the term names you need to run the array through a map first:

    echo '[' . esc_html(
            ', ',
                function( $term ) {
                    return $term->name;
    ) . ']';
    • This reply was modified 11 months, 2 weeks ago by Daniel Llewellyn. Reason: fix new code
    <?php $terms = get_the_terms( $post, 'especialidades' ); if ( $terms ) : echo '[' . esc_html( implode( ', ', array_map( $terms, function( $term ) { return $term->name; } ) ) ) . ']'; endif; ?>

    I did it this way, where “especialidades” is the name of my custom taxonomy. And yet I can not display, shows me nothing. Would you help me ?

    • This reply was modified 6 months, 2 weeks ago by visaoativa.
    • This reply was modified 6 months, 2 weeks ago by visaoativa.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add Taxonomy title to index name’ is closed to new replies.