• Hi,

    Before last update, I added a personal shortcode in my functions.php file in order to filter not by title, but by slug (postname), which gave smth like this (thus, titles are like “surname Name” whereas postnames are like name-surname):

    add_shortcode( ‘sf_a_z_listing’, ‘sf_a_z_listing_func’ );
    function sf_a_z_listing_func($atts){
    $a = shortcode_atts( array(
    ‘category_name’ => ”,
    ‘post_type’ => ‘page’,
    ‘category__not_in’ => ”,
    ‘orderby’ => ‘postname’
    ), $atts, ‘sf_a_z_listing’ );

    $cat_exclude = explode(‘,’,$a[‘category__not_in’]);
    $a[‘category__not_in’] = array_map(‘trim’, $cat_exclude);
    return the_a_z_listing( $a );

    It seems now that we cannot not override the query…
    Any idea on how to do it again?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter soisita


    If it helps, I’ve been back to your shortcode, but with some changes on the shortcode handler (which is not nice, I know, unless you add this to a future version 🙂 ):

    function a_z_shortcode_handler( $attributes ) {
            $attributes = shortcode_atts(
                            'column-count' => 1,
                            'minimum-per-column' => 10,
                            'heading-level' => 2,
                            'display' => 'posts',
                            'post-type' => 'page',
                            'taxonomy' => '',
                            'terms' => '',
                            'numbers' => 'none',
                    'category-not-in' => '',
                    ), $attributes, 'a-z-listing'
            if ( ! empty( $attributes['taxonomy'] ) && 'terms' === $attributes['display'] ) {
                    $a_z_query = new A_Z_Listing( $attributes['taxonomy'] );
                    return $a_z_query->get_the_listing();
            $excludecat = explode( ',', $attributes['category-not-in'] );
            $excludecat = array_map( 'trim', $excludecat );
            $excludecat = array_unique( $excludecat );
            $post_types = explode( ',', $attributes['post-type'] );
            $post_types = array_map( 'trim', $post_types );
            $post_types = array_unique( $post_types );
            $query = array(
                    'post_type' => $post_types,
                    'category__not_in' => $excludecat,

    and the shortcode example:
    [a-z-listing post-type="post" taxonomy="category" terms="horses" orderby="postname" category-not-in="1,53"]

    My other concern now is to index the listing based on slug and not title…
    Meaning I want my posts to be sorted and grouped by letters based on slug (postname), but with titles displayed below the letters

    Mickael Andrew

    Katie Douglas

    (and the slugs being andrew-mickael, douglas-katie)

    The “orderby” I used before seems not to work on “tax_query” and I don’t want to go too deep into your class 🙂


    Plugin Author Dani Llewellyn


    Thanks for the ideas, I’ll look to incorporate them, or a variant, in a future iteration.

    I’m sorry I didn’t get to your query before you’d found a workaround that works for you. Good work on getting everything working! 😀

    Thread Starter soisita


    Hi Daniel,
    No pb… Thanks for the reply 🙂
    Actually, if we could add a shortcode the way I did before last update, or if you accept in the shortcode more arguments, that would be perfect 🙂

    Thread Starter soisita


    Hi Daniel,
    Any news about this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Order by postname’ is closed to new replies.