• I have a referral list (name and address info) that I want to display in 2 columns in a wordpress post and I also need it to be alphabetized like below
    A B
    C D
    E F
    G H
    and so on

    Anyone have some coding suggestion? I’m a tweaker and not good with code.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • How are you making the list for referrals?

    Are you looking for help generating the list and alphabetizing it, or getting an existing list into two columns on a WordPress page?

    Thread Starter ccarlow

    (@ccarlow)

    Thanks for your reply Ancawonka!

    Yes I need help with some kind of code that formats an existing list into 2 columns and also alphabetize the list based on a persons last name.

    The referral list is here: https://risaom.org/referral-list/

    It contains basically names and addresses. My hope is to make it easy to format and update.
    Format meaning – putting the list into 2 columns and alphabetize it like this pattern below
    A B
    C D
    E F
    and so on

    I would like to make the list easy to update…It would be great if I can edit a word post and just simply add a new name/address to the bottom of the page code and have custom code that would alphabetize it so i don’t have to alphabetize it manually and re-adjust the columns to make the name/address fit.

    I’d like to alphabetize on the last name or some hidden number scheme.

    If you have any ideas or even alternative thinking that can streamline the updating process. That would be helpful.

    Moderator bcworkz

    (@bcworkz)

    Ideally this data should be maintained in a database table accessible to WP. Then getting the data is a matter of making an SQL query. Coding the user interface is a sizable coding project though.

    The data could also be managed as a custom post type with custom fields. Then WP will help you manage the user interface. This could be a challenging but doable plugin project if you want to get into coding more.

    If you want something workable with minimal effort, establish the data as a PHP array declaration. While the format would be highly structured, once the structure is established, adding more data is fairly straight forward. You could maintain an array element template as a PHP comment from which you copy the structure into the main array, filling in the data as required.

    Since sorting PHP arrays is easy and flexible, the order of the entries makes no difference, but the structure needs to be strictly adhered to. The data array could then be included on a custom page template that contains the loop that steps through the array and outputs the data after it is sorted.

    There’s all sorts of loop schemes to manage left/right output. For example, maintain a loop counter and output left or right HTML based on the counter value modulo 2 result. Or output everything as an unordered HTML list (the data is ordered, not the HTML) and use jQuery’s Masonry to parse everything into a pleasant structure.

    Hi @ccarlow. Take a look at the “Connections” plugin – this might do what you want (though you’ll have to maintain the list as a set of posts, which is alphabetized by the display template).

    https://www.ads-software.com/plugins/connections/

    Thread Starter ccarlow

    (@ccarlow)

    thanks everyone! Ancawonka, I think I’ll give connections a try.

    Thread Starter ccarlow

    (@ccarlow)

    Alright – I got it setup. It’s a little uneven – the separate listings aren’t listed exactly side by side because some listings are longer than others and some sections get skipped but it kind of works. I need to play with it more.

    https://risaom.org/referral-list/

    hi there, i will give you a link that you may review and do it also that might help you (so many info, hard to type) just read this. . .
    https://www.elegantthemes.com/blog/tips-tricks/how-to-create-column-layouts-in-wordpress

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to make a 2 column div in a WP post that is alphabetized’ is closed to new replies.