• Resolved pilotspelman

    (@pilotspelman)


    Hello,

    I’ve seen others struggle with the same issue but have yet to find a straight answer to how to make it work.

    I’m using the WP theme Twenty Twentyfour in combination with Pods and have created a CPT with custom fields. In Twenty Twentyfour, you can easily create templates for individual posts and archives. Templates work as intended for individual posts, including auto templates. However, I still need to figure out a solution for archive templates. The archive is certainly displayed, but only, e.g., regular headings.

    I have activated the Excerpt option in the “Advanced Tab ” and tried enabling “Auto template” with “Filter: the_excerpt.”

    So the Pods Blocks display nothing, and nor does the Auto template.

    My idea is to use IF conditional tags to show with an icon, e.g., if some PDF document is attached to the post (one of the custom fields).

    As an experiment, I have now tried the Plugin “Meta Field Block,” and for some reason, that works, but the native Pods blocks don’t. Of course, I would like to get the native Pods blocks to work, even in the Archive templates, but how?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Paul Clark

    (@pdclark)

    Auto templates are for classic themes which do not have templates editable outside PHP, but might use the excerpt or archive description hooks.

    For themes using Full Site Editing like TwentyTwentyFour, blocks Pods Single Item, Pods Field Value, Pods Single Item - List Fields, or Pods Related Item List can be used within the Query Loop block.

    An Archive template already contains a loop for the archive query, viewable as the Query Loop block in the left List View sidebar. It usually contains default blocks like Title, Featured Image, and Post Meta.

    Nothing will appear when the blocks are first inserted. To get started, write a template in the Custom Template field of the block options, following the syntax {@field_name} where field_name is a name of a custom field that has been defined on the post type, or any WordPress core column from the wp_posts table.

    For example:

    <p><a href="{@permalink}">{@post_title}</a></p>

    See: docs.pods.io > Magic Tags

    For more complex queries, one may also use a shortcode block with the Pods shortcode.

    Plugin Support Paul Clark

    (@pdclark)

    For an if statement if a file field exists, this template would be a start:

    [if pdf_field]
    <a href="{@pdf_field}">
    <img src="https://picsum.photos/50" /> Download {@pdf_field.post_title}
    </a>
    [/if]

    Where:

    • [if field_name] ... [/if] documentation can be found at docs.pods.io > IF/ELSE Conditional Tag.
    • The field is named pdf_field of type File / Image.
    • {@pdf_field} will output the URL to the file unless field settings are changed to output a full HTML link.
    • {@pdf_field.post_title} will output the name of the file.
    Thread Starter pilotspelman

    (@pilotspelman)

    Thanks, Paul; I really appreciate you taking the time with this in-depth explanation!
    Unfortunately, my dilemma remains for some reason. In the block editor, it looked promising and still looks great. I.e., different icons appear due to the “if-field-logic,” just as I expected. I have used the Pods Single Item block inside the Query Loop, as shown in the attached screenshot. For now, I also left the default Title block (until I get the Pods blocks working).

    The code in the Custom Template field looks like this:

    <style>
    img.latvalign {
    vertical-align: middle;
    float: right;
    }
    </style>
    <div style="padding-bottom: 5px;">
    [if noter]
    <img class="latvalign" src="https://olfm2.jansson-fam.se/wp-content/uploads/icons/musical_notes_icon.png" />
    [/if]
    [if inspelning]
    <img class="latvalign" src="https://olfm2.jansson-fam.se/wp-content/uploads/icons/recording_icon.png" />
    [/if]
    [if lank]
    <img class="latvalign" src="https://olfm2.jansson-fam.se/wp-content/uploads/icons/link_icon.png" />
    [/if]
    [if midi-fil]
    <img class="latvalign" src="https://olfm2.jansson-fam.se/wp-content/uploads/icons/MIDI_icon.png" />
    [/if]
    </div>

    Unfortunately, nothing of the Pods Custom Template is still visible on the frontend (only the ordinary Title Block), and of course, I am logged in as an administrator.

    Do you have further suggestions on what I should check?

    I vaguely remember having to change something in wp-config.php, but I can’t remember where I read that.

    As I wrote, the pod templates work exactly as expected for individual posts, but unfortunately not for archives.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.