• Im trying to link to my post archive url but It’s adding the ” ” weird and I cant actually create a link.

    I can loop through and show the titles and the urls with:

    <ul>
    [for type=all]
      <li><a href="[each url]">[each name]</a></li>
    [/for]
    </ul>
    

    But this isn’t working

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

    [for type=all]
    [pass field=url]
      <li><a href="{FIELD}">[each name]</a></li>
    [/pass]
    [/for]
    • This reply was modified 4 years, 1 month ago by polarracing.
    Thread Starter theshae

    (@theshae)

    That didn’t work. It’s listing all of the post types with a link, but ALL of the URL’s are to the home page and not the archive page.

    Thread Starter theshae

    (@theshae)

    <ul>
    [for type=all]
      <li><a href="[each url]">[each name]</a></li>
    [/for]
    </ul>

    This is the result I get
    https://www.evernote.com/l/ALGwTuizR6lEs7U6dgJ4AOFfGO8S00IqeRM

    The following prints the URL inside of quotes.

    <ul>
    [for type=all]
      <li>[each url]</li>
    [/for]
    </ul>

    See here:
    https://www.evernote.com/l/ALH4yo1jMf1DILlEwQgRvxCoS8ccGkVdsL4

    If I try the code like this without the quotes on the href like this:

    <ul>
    [for type=all]
      <li><a href=[each url]>[each name]</a></li>
    [/for]
    </ul>

    I get this:
    https://www.evernote.com/l/ALFkwNUG2m1D9aK_LYGHio2C_kkql1BayZQ

    Any ideas why this happens?

    • This reply was modified 4 years, 1 month ago by theshae.
    • This reply was modified 4 years, 1 month ago by theshae.
    • This reply was modified 4 years, 1 month ago by theshae.

    Would you try it with single quotes?

    Thread Starter theshae

    (@theshae)

    I’ve tried that too. Still not working. Is anyone else getting the same results?

    *I hope this would help others as references:

    <ul>
    [for type=all]
      <li><a href=[each url]>[each name]</a></li>
    [/for]
    </ul>

    is wrong if you are posting them through WordPress text editor.

    Always pass vars into a functioning attributes of any HTML element.

    Correct example that works for me:

    <ul>
    [for type=all]
      [set varurl][each url][/set]
      [pass vars]
      <li><a href="{VARURL}">[each name]</a></li>
      [/pass]
    [/for]
    </ul>

    note: unless you set the ” in the var, otherwise url attribute needs to open&close with ” as it is.

    I also avoid using -/_ when naming set vars eventhough it may not be relevant to the errors I got but not using them fixed my problems so I just consider this as a good practise to go.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with post type archive url’ is closed to new replies.