• Resolved jesterpants

    (@jesterpants)


    Hey,

    My PHP is too week.

    I’m using shortcode “[catlist offset=0 taxonomy=’portfolio_category’ terms=’men’ orderby=title order=asc numberposts=20]”

    To order clients for an actors site. I’ve had a request to list them alphabetically by the last name. However, they are just a single title string.

    I tried creating a new shortcode for “title2” subtracting the first word from the title before applying “order” – yep I just broke the plug-in.

    Any help would be very much appreciated.

    :))

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor zymeth25

    (@zymeth25)

    Hi

    Well, you cannot just ‘subtract’ first names. Technically you could with custom SQL and PHP but I don’t recommend it. These are the options if we are not using custom PHP:

    • Simply change every title to [last name] [first name]. However, that might not be acceptable so you could do something else:
    • Add a custom field called lastname to every post. In that custom field save each actor’s last name (preferably lowercase for clarity). Then modify your shortcode a bit [catlist offset=0 taxonomy='portfolio_category' terms='men' customfield_orderby='lastname' order=asc numberposts=20] It’s a bit of a hassle to set this up but it should work fine.

    Cheers

    • This reply was modified 6 years, 11 months ago by zymeth25.
    Thread Starter jesterpants

    (@jesterpants)

    Hey,

    Thanks for the speedy reply.

    The last solution works brilliantly.

    What a relief – and no PHP meddling…

    Thank you so so much.

    Thread Starter jesterpants

    (@jesterpants)

    Worked like a charm.

    https://nancyhudsonassociates.com/client-list-2/

    Thanks again :))

    Plugin Contributor zymeth25

    (@zymeth25)

    Glad it worked ??

    • This reply was modified 6 years, 11 months ago by zymeth25.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘order by (skip first word)’ is closed to new replies.