• Resolved Nevrion


    Hello, I am also trying to sort a list ASC. I tried this example:


    But whenever I try to save a page with this shortcode, I get an MSQL error.

    When I paste it into a template, there is no output.

    My Template:

    My Shortcode:

    [pods name=”crew” where=”mcs.ID = {@ID}” template=”crew_mcs” orderby=”post_title”]

    I want to sort the values in MCs in the Pod Crews.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jim True


    What’s the actual MySQL error you’re getting? That will help us troubleshoot your issue above. You might also want to surround your template above with the code tags in the editor box so we can see what you’re actually including in your template above.

    Also, you can’t use a shortcode like where="mcs.ID = {@ID}" unless you’re in a context where it can _read_ that magic tag {@ID}, ie inside a Pods Template. That’s what we discussed in https://wordpress.org/support/topic/using-each-how-to-sort-order-by/#post-10386920. You have to call that shortcode from another template, so in your case you’d actually be using a shortcode to call a template that calls a shortcode to sort the related records and output those in another template.

    • This reply was modified 2 years ago by Jim True. Reason: misspelled word


    That was probably a problem of understanding on my part. Since it did not seem to work in the template, I tried it in a post.

    I am very inexperienced in this whole PHP and coding world. In addition, I have to hunt some terms through Google Translate because they are not familiar to me.

    I tried to use the shortcode in the template crew_profile. The output was empty, I assume that I basically just have problems understanding how it interlocks.

    Currently it looks like this:

    crews_profile template

    [if mcs]
    <center><ul class="mcs" >
    		[each mcs]
    	 <td hight="150" align=center><a href="{@permalink}"><img hight="150px" width="150px" src="{@mcs.post_thumbnail_url.large}" title="{@post_title}"></a></td>

    Here, the crew members are currently displayed to me, but not in alphabetical order.

    MCs are a custom post type I have associated with the Custom Post Type crew.

    Now I tried to do the sorting with the template crew_mcs

    [each mcs]
    	<a href="/{@permalink,esc_url}">{@post_title}</a>

    And then try to include the shortcode in crew_profile

    [pods name=”crew” where=”mcs.ID = {@ID}” template=”crew_mcs” orderby=”post_title”]

    If I only use the shortcode, the page stays empty (which I now understand, because the shortcode does not know what value he should work with)

    [each mcs]
    [pods name=”crew” where=”mcs.ID = {@ID}” template=”crew_mcs” orderby=”post_title”]

    That’s why I tried to involve him so … but he also gives the wrong result because he now outputs all entries for each entry, but these are not sorted.

    I hope it is at least meaningful to understand … I translate everything with google translate because I’m very uncertain in my English gramatik.

    Many thanks for your help



    I really do not seem to be gifted enough for it. I’ve been trying back and forth for several hours, I’m just not capable of it.



    [pods name=”crew” where=”mcs.ID = {@ID}” template=”crew_mcs” orderby=”post_title” slug=”{@post_title}”]

    Now I have tried this way. Now contents are also displayed but not sorted.

    However, nothing is sorted.

    Plugin Author Jim True


    I think some of the confusion is the language issue in my description. Can you let us know your native language? I might be able to find a translator to help you out. By default, the post_title should be the native sort, btw.

    The process is like the following:

    1. You’re trying to sort content that is related to the current post. You either want this to happen on one post or automatically with Auto Templates, so the Pods Template you’re calling is for the Related Items sorted in a specific way. If it’s part of the existing Post Detail Pods Template for the current post, you can do this like step #2. However, if you’re calling this inside the current post in a builder, your template needs to be something like the following:
      [pods template="Related Items for this Post Sorted by Custom Field"]
    2. Inside the template “Related Items for this Post Sorted by Custom Field”, you’re only going to put one line, the shortcode to call the related items sorted:

      [pods name="Related Post Type" where="related_to_this_post.ID = {@ID}" orderby="custom_field" template="Related Item List"]

      If this is inside your singular post detail, you can use this in place of where you would do an [each related_field][/each] block:

      I’m using generic names above, but:
      Related Post Type is the post type of the list of items that are related to your current post type that you are trying to order. You must have a relationship field between them that is configured bidirectionally.
      related_to_this_post.ID is the relationship field in the related post type that points back to the current post type.

    3. The template ‘Related Item List” is just a template to output a list of items from the Related post type. The shortcode being called in step 2 is what limits the records to those matching your parent post or current post type and the order by works against them.
      All that has to be in it is the following:

      <li><a href="{@permalink,esc_url}">{@post_title}</a></li>

    I hope that helps as it’s more step by step and example based.

    • This reply was modified 2 years ago by Jim True. Reason: fixing formatting
    • This reply was modified 2 years ago by Jim True.
    • This reply was modified 2 years ago by Jim True.
    Plugin Author Jim True


    To bring it back to CREW and MCS

    1) Call a shortcode IN your Auto Template or Crew Profile Pods template that will run against MCS

    [pods name="mcs" where="mcs.ID = {@ID}" template="mcs list" orderby="post_title"]

    This can _only_ be ran inside a template, because it’s using the value of the current post’s ID to get the right related items. The only magic tag allowed in that is the ID because if you use {@post_title} that will be replaced by the Crew’s post-title in the template.

    2) MCS List only needs to contain the output for a list, the [each][/each] syntax is only used against related items INSIDE the current template. You’re calling a shortcode to pull the list from another template, so you can’t use each: the shortcode will pull the right list and feed that list to template that will just output the MCS list.

    3) Not sure why you had slug=”{@post_title}” as nothing we’re dealing with was needing that specifically.



    Hello Jim, I’m speechless about your helpfulness, many thanks. I’m from Germany, but I think in my case that’s more of a logic problem than a language issue.
    That’s really bitter for me.
    I’d like to do a lot of things with pods, but I’ll fail because of a simple sorting of names.

    I do not get it even after your detailed explanation. Nothing is displayed in the crew profile, no matter how I try it, I’m really failing in the understanding of function.

    I tried several variations, and either there was a Mysql error message (I understood that by now, they came when I wanted to retrieve an entry in a pod that does not exist in the pod) others just stay blank.



    I would like to come back to it because it just does not let me go.

    My custom post type for mcs is called “mc”. My custom post type for crews is called “crew” MCs within a crew are called “mcs”.

    I have now tried many konstalationen back and forth in the end it is so if I “mcs” in the second template list I can with the shortcode (only template, without sorting) show. As soon as I have “where” in the shortcode, nothing is displayed anymore … I’m really obsessed. If you know someone who can really help me in German, I would be very grateful.

    Plugin Author Jim True


    You’re really going to have to join our Slack Chat. If you’re not getting it from the detailed explanation above, I won’t be able to help you without actually walking through it with you in a chat interface.

    https://pods.io/chat/ in our #support channel.

    I’m sorry, but I don’t know how else to help you on that one.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘sort/order by’ is closed to new replies.