• Resolved fyfluids

    (@fyfluids)


    Hi all,

    I’m a new user of PODS, trying to get a site I’m developing for a client up and running. I’ve created a Custom Post Type for publications and I’m trying to write a template that will display each publication and the desired custom fields inside a WordPress page.

    Here’s the template code I’m using:

    [each post_title]
    	<p> <a href="{@link}">{@article_title}</a><br/>
    		{@author_1} [if @author_2], {@author_2} [/if] [if @author_3], {@author_3}[/if] [if @author_4], {@author_4}[/if] [if @author_5], {@author_5}[/if] [if @author_6], {@author_6}[/if] [if @author_7], {@author_7}[/if] [if @author_8], {@author_8}[/if] [if @author_9], {@author_9}[/if] [if @author_10], {@author_10}[/if] <br/>
    		<i>{@journal}</i>, {@publication_year}, {@pubstatus} <br/> </p>
    [/each]

    And I call that template using a shortcode in the WordPress page:

    [pods name="publication" orderby=publication_year template="Publications"][/pods]

    Right now the only thing that renders in the page are the commas “, ,” from the last line of the template code. (They appear for the correct number of publications, so there’s that, I guess.) No field information whatsoever appears, even in the HTML source. I can get the custom field magic tags to render if I list them between the [pods][/pods] shortcode, but, in that case, they don’t respond to the conditionals.

    In my own troubleshooting, I’ve reverted to the default TwentyTwenty theme and disabled all other plugins. None of those changes affected the behavior. I’ve also simplified the template by removing the link and all the “if” conditionals, but that also makes no difference.

    I’m sure I’m missing something simple, but I can’t for the life of me figure out what. Thanks for your help!

    Best,
    Nicole

Viewing 1 replies (of 1 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @fyfluids

    Have you checked our introduction video Grow? https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/

    In any case, the shortcode itself is already a loop so why are you adding an [each] loop in the template? And besides that, why is the each loop on the post_title, there is always only 1 post title right? I also see {@article_title}, is this a custom field or should this be {@post_title}?

    And as last, (just a tip!) I see you’ve added a lot of if statements for authors. Did you make 10 separate custom fields for authors? If so, I’d advice you to switch to a different setup:

    – Create a new custom post type called “Authors”. (or if the authors should also be users on your system you could use the users itself).
    – Then create a multiple relationship field called rel_authors from the Publication to the Author (I always prefer the List View UI, see advanced settings).

    Now you can add as many relationships as you want and just use tag: {@rel_authors}. Or you can create a sub-template to show these.
    Another improvement is that you could make this field bi-directional and create author pages to list all their publications as well.
    No need to manually predetermine the amount of possible authors and number the fields. Just create a single relationship field. This is way more flexible!

    Hope this helps!

    Cheers, Jory

Viewing 1 replies (of 1 total)
  • The topic ‘Magic tags not rendering from templates’ is closed to new replies.