• Resolved mehmetba

    (@mehmetba)


    I know the start parameter which can be used with field. What I’m trying to do is to list taxonomy terms which start with certain lettes, for example A.

    I’ve tried this to no avail:

    <ul> [for each=apple start=A] <li>[each link]</li> [/for]
    </ul>

    How to list all taxonomy terms starting with, say, the letter A?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try something like this:

    [pass list='A~Z']
     [for each=apple]
      [if each_field=name start='{ITEM}']
       [each link]
      [/if]
     [/for]
    [/pass]

    If this is not working, set a variable with [each name] and run the if-statement against the variable.

    • This reply was modified 3 years, 9 months ago by polarracing.
    Thread Starter mehmetba

    (@mehmetba)

    @polarracing , thank you for taking the time and answering my question.

    The above code did not work. It lists all the taxonomy terms.

    About setting variables with [each name], could you please elaborate your answer? I did not get it.

    Thanks.

    Hi, this works for me – it sorts the taxonomy by term-name. Simply replace the cat name and use:

    [pass list='A~Z']
    [for each=cars_touring_cat]
    [set test][each name][/set]
    [if var=test start='{ITEM}']
    [get test]
    [/if]
    [/for]
    [/pass]

    You can add the actual list item with {ITEM}. To get only terms with ‘A’ change the passed list.

    • This reply was modified 3 years, 9 months ago by polarracing.
    Thread Starter mehmetba

    (@mehmetba)

    Perfect! Thanks for your informative answer.

    Thread Starter mehmetba

    (@mehmetba)

    One more thing:

    How to convert the taxonomy names into taxonomy links?

    I’ve tried:

    [pass list='A']
    [for each=custom_taxonomy]
    [set test][each name][/set]
    [if var=test start='{ITEM}']
    <a href="[url]/custom_taxonomy/[get test]">[each name]</a>
    [/if]
    [/for]
    [/pass]

    However, this doesn’t recognize the [get test]. It only directs to : https://www.mysite.com/custom_taxonomy

    • This reply was modified 3 years, 9 months ago by mehmetba.
    • This reply was modified 3 years, 9 months ago by mehmetba.
    Thread Starter mehmetba

    (@mehmetba)

    For the record, this is how I managed it:

    [pass list='A']
    [for each=custom_taxonomy]
    [set test][each name][/set]
    [if var=test start='{ITEM}']
    <ul class="my_class"><li class="my_class">[each link]<span class="my_class_count">[loop-count type=custom_post_type taxonomy=custom_taxonomy]</span></li></ul>
    [/if]
    [/for]
    [/pass]
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List taxonomy terms which start with certain letter’ is closed to new replies.