pods icon indicating copy to clipboard operation
pods copied to clipboard

[each] not working in Pods template with default taxonomies

Open abrightclearweb opened this issue 10 years ago • 2 comments

WordPress version 4.5.3 Pods version 2.6.6

I have a Pod, Papers, which has 2 custom fields, Discussion and Download. Papers has another custom taxonomy Authors assigned to it. It also uses the built-in taxonomies Categories and Tags.

I have created a Pods template to display it, Paper Template. It's set as the Single Item View Template. Location Replace, Filter the_content.

Here is my Paper Template code:

<div class="quarter">
        <div class="rm-infobox author">
            [each author]
            [if description]    
                <h2>{@name}</h2>
                <p>{@description}</p>

            [else]
                <h2>{@name}</h2>
            [/if]
            [/each]
            </div>
            <a href="#sidebar">Skip to Download/Discussion</a>
        [each category]
        <a href="{@permalink,esc_url}">{@name}</a>
        [/each]
        [each post_tag]
        <a href="{@permalink,esc_url}">{@name}</a>
        [/each]
            </div>
            <div class="three-quarter paper-content">
            {@post_content}
            </div>


When I use this with a Paper with one category and 3 tags, the category and tag output is: Pod not found

The error message with WP_DEBUG reporting turned on is:

Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/divi/wp-content/plugins/pods/components/Templates/includes/functions-view_template.php on line 253

The problem seems to be related to the category and post_tag taxonomies.

If I change my code and use the original taxonomy I created, paper_category, the category name outputs okay, though the permalink is wrong (it's simply the taxonomy slug, misc). But at least it fetches the data.

[each paper_category]
        <a href="{@permalink}">{@name}</a>
        [/each]

Screenshots attached. paper - back end paper - front end

abrightclearweb avatar Jul 29 '16 16:07 abrightclearweb

With your paper_category taxonomy, you can workaround the permalink issue with:

[each paper_category]
<a href="/paper-category/{@slug}">{@name}</a>
[/each]

Basically "hard-coding" the url of the taxonomy into the link. This particular item might actually be fixed on pods.io/latest/ (our current Dev Branch), because we pushed a fix in to properly traverse taxonomy.

jimtrue avatar Jul 29 '16 17:07 jimtrue

#3339 Fixed this issue.

jimtrue avatar Jun 10 '17 23:06 jimtrue