• Hi, great plugin!

    I have a page which shows posts that are a custom post type called ‘writers’, the trouble is that the Writer names are put into the post title field (first name, surname) meaning that the A-Z only works by first name. I thought I could use the ACF plugin to create a custom field called ‘A-Z surname’ or similar and use that but cannot quite make it work. Is it possible? or is there a better way to achieve what I am aiming for?

    Many thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dani Llewellyn

    (@diddledani)

    It might be possible to do this by adding some PHP code that hooks into the filter called a_z_listing_item_indices:

    https://a-z-listing.com/reference/hooks/a_z_listing_item_indices/

    The return value needs to be of the format:

    return array( $index_letter => array( array(
        array(
            'title'     => get_the_title( $post ),
            'item'      => $post, // the post object as passed into the function
            'permalink' => get_the_permalink( $post ),
        )
    ) );

    Yes there is a double-nested array, allowing for you to add multiple index letters for the same post, or multiple instances under the same index letter.

    You’ll need to take the title from the post and perform your custom match to find the correct index letter (last name’s first letter) and use that in your return.

    Thread Starter biscuitier0

    (@itsaskew)

    Thanks very much for your reply.

    Unfortunately this poses something of a puzzle for my current level of php understanding. Are we talking about adding your code above to the functions.php as part of a function, something like the one you talk about here? https://www.ads-software.com/support/topic/sort-posts-on-a-custom-fields-value/

    Any extra info you could give would be greatly appreciated

    Plugin Author Dani Llewellyn

    (@diddledani)

    Yes, exactly like that.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using the plugin with advanced custom fields’ is closed to new replies.