Support » Plugin: A-Z Listing » Filter posts via category using shortcode

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

    (@diddledan)

    Hi,

    I’m working on an updated version of the short-code to allow filtering by taxonomy terms, but it isn’t ready just yet. Depending on how I get on it might land later today 🙂

    With the PHP method of accessing the listing the taxonomy-slug, field and terms are all direct parallels to the WP_Query object. As the WordPress.org team are better at explaining things I have left the documentation of the taxonomy parameters up to the Codex for now.

    Hi Daniel,

    Thank you for getting back to us so quickly. It restores our faith in free plugins and their authors!

    We’ll wait for you to confirm the shortcode feature has been added. Are you almost done?

    Thanks!

    Also, in the interim, if we decide to use PHP code, will the following work?

    <?php
    the_a_z_listing( array(
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘slug’,
    ‘terms’ => array( ‘fashion’ )
    ) );
    ?>

    Plugin Author Daniel Llewellyn

    (@diddledan)

    Hi,

    Nearly, you need a minor tweak to work:

    <?php
    the_a_z_listing( array(
        'tax_query' => array( array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => array( 'fashion' )
        ) )
    ) );
    ?>

    Written as above, it will show all posts which have been assigned the term fashion from the taxonomy category (categories). If you wanted to specify a post type, then you can do something like below (this example uses page as the post type):

    <?php
    the_a_z_listing( array(
        'post_type' => 'page',
        'tax_query' => array( array(
            'taxonomy' => 'category',
            'field' => 'slug',
            'terms' => array( 'fashion' )
        ) )
    ) );
    ?>

    tax_query is an array of arrays, so it can get confusing. If in doubt check the WP_Query documentation.

    The field attribute in the tax_query usually remains constant, assigned the value slug, but it must be specified to conform to WP_Query semantics)

    Plugin Author Daniel Llewellyn

    (@diddledan)

    Hi,

    I’ve just released version 1.7.0, which includes the ability to filter by taxonomy. If I’ve got it right you should now be able to use the following shortcode:

    [a-z-listing taxonomy="category" terms="fashion"]

    Very Useful feature . Thanks A lot !
    But I test it and it doesn’t show any post title !
    The only configuration that I did is to translate strings .

    add_filter( 'a_z_listing_alphabet', 'replace_a_z_alphabet' );
    function replace_a_z_alphabet( $alphabet ) {
        return 'اآ,ب,پ,ت,ث,ج,چ,ح,خ,د,ذ,ر,ز,ژ,س,ش,ص,ض,ط,ظ,ع,غ,ف,ق,ک,گ,ل,م,ن,و,ه,ی ي';
    }

    Is it because of that ?

    Plugin Author Daniel Llewellyn

    (@diddledan)

    It’s possible the matching of “multi-byte characters” is a bit wonky (broken). Being an English speaker I rarely use non-latin letters which makes me less able to anticipate non-English locales. I have tried my best to cope by using PHP’s “multi-byte string” (mbstring) module to cope with characters made of multiple individual codes combined into a single glyph, but I’m not an expert at unicode so I am likely to have got it wrong. I’ll try to replicate your issue by copy+paste (non-English letters are difficult to type on an English keyboard) to see if I can find the problem.

    Works perfectly! Thanks!

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